thw plugins: fix only_hook_if_libraries_available - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 70c32590a9bdfccc1ff6896d0fc558fb163c203a (DIR) parent ce5cc135cd432552006c713d1d83d9fb51e1e7e2 (HTM) Author: SomberNight <somber.night@protonmail.com> Date: Sun, 30 Sep 2018 00:25:36 +0200 hw plugins: fix only_hook_if_libraries_available follow-up f9a5f2e1835e8326d1d030a6e79bd148455ee6be Diffstat: M electrum/plugins/coldcard/qt.py | 4 ++-- M electrum/plugins/digitalbitbox/qt.… | 2 +- M electrum/plugins/hw_wallet/plugin.… | 2 ++ M electrum/plugins/keepkey/qt.py | 2 +- M electrum/plugins/ledger/qt.py | 2 +- M electrum/plugins/safe_t/qt.py | 2 +- M electrum/plugins/trezor/qt.py | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) --- (DIR) diff --git a/electrum/plugins/coldcard/qt.py b/electrum/plugins/coldcard/qt.py t@@ -17,8 +17,8 @@ class Plugin(ColdcardPlugin, QtPluginBase): def create_handler(self, window): return Coldcard_Handler(window) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return t@@ -28,8 +28,8 @@ class Plugin(ColdcardPlugin, QtPluginBase): keystore.thread.add(partial(self.show_address, wallet, addrs[0])) menu.addAction(_("Show on Coldcard"), show_address) - @hook @only_hook_if_libraries_available + @hook def transaction_dialog(self, dia): # see gui/qt/transaction_dialog.py (DIR) diff --git a/electrum/plugins/digitalbitbox/qt.py b/electrum/plugins/digitalbitbox/qt.py t@@ -16,8 +16,8 @@ class Plugin(DigitalBitboxPlugin, QtPluginBase): def create_handler(self, window): return DigitalBitbox_Handler(window) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return (DIR) diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py t@@ -138,6 +138,8 @@ def trezor_validate_op_return_output_and_get_data(output: TxOutput) -> bytes: def only_hook_if_libraries_available(func): + # note: this decorator must wrap @hook, not the other way around, + # as 'hook' uses the name of the function it wraps def wrapper(self, *args, **kwargs): if not self.libraries_available: return None return func(self, *args, **kwargs) (DIR) diff --git a/electrum/plugins/keepkey/qt.py b/electrum/plugins/keepkey/qt.py t@@ -195,8 +195,8 @@ class QtPlugin(QtPluginBase): def create_handler(self, window): return QtHandler(window, self.pin_matrix_widget_class(), self.device) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return (DIR) diff --git a/electrum/plugins/ledger/qt.py b/electrum/plugins/ledger/qt.py t@@ -17,8 +17,8 @@ class Plugin(LedgerPlugin, QtPluginBase): def create_handler(self, window): return Ledger_Handler(window) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return (DIR) diff --git a/electrum/plugins/safe_t/qt.py b/electrum/plugins/safe_t/qt.py t@@ -71,8 +71,8 @@ class QtPlugin(QtPluginBase): def create_handler(self, window): return QtHandler(window, self.pin_matrix_widget_class(), self.device) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if len(addrs) != 1: return (DIR) diff --git a/electrum/plugins/trezor/qt.py b/electrum/plugins/trezor/qt.py t@@ -166,8 +166,8 @@ class QtPlugin(QtPluginBase): def create_handler(self, window): return QtHandler(window, self.pin_matrix_widget_class(), self.device) - @hook @only_hook_if_libraries_available + @hook def receive_menu(self, menu, addrs, wallet): if len(addrs) != 1: return