electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f9a5f2e1835e8326d1d030a6e79bd148455ee6be
parent 8caab35d90087f413ec330c29ffa7a61d6c378a2
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 19 Sep 2018 20:02:03 +0200

fix #4698

Diffstat:
Melectrum/plugins/coldcard/qt.py | 3+++
Melectrum/plugins/digitalbitbox/qt.py | 8+++++---
Melectrum/plugins/hw_wallet/plugin.py | 7+++++++
Melectrum/plugins/keepkey/qt.py | 2++
Melectrum/plugins/ledger/qt.py | 2++
Melectrum/plugins/safe_t/qt.py | 2++
Melectrum/plugins/trezor/qt.py | 2++
7 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/electrum/plugins/coldcard/qt.py b/electrum/plugins/coldcard/qt.py @@ -7,6 +7,7 @@ from electrum.gui.qt.util import * from .coldcard import ColdcardPlugin from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available class Plugin(ColdcardPlugin, QtPluginBase): @@ -17,6 +18,7 @@ class Plugin(ColdcardPlugin, QtPluginBase): return Coldcard_Handler(window) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return @@ -27,6 +29,7 @@ class Plugin(ColdcardPlugin, QtPluginBase): menu.addAction(_("Show on Coldcard"), show_address) @hook + @only_hook_if_libraries_available def transaction_dialog(self, dia): # see gui/qt/transaction_dialog.py diff --git a/electrum/plugins/digitalbitbox/qt.py b/electrum/plugins/digitalbitbox/qt.py @@ -1,12 +1,13 @@ from functools import partial -from ..hw_wallet.qt import QtHandlerBase, QtPluginBase -from .digitalbitbox import DigitalBitboxPlugin - from electrum.i18n import _ from electrum.plugin import hook from electrum.wallet import Standard_Wallet +from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available +from .digitalbitbox import DigitalBitboxPlugin + class Plugin(DigitalBitboxPlugin, QtPluginBase): icon_unpaired = ":icons/digitalbitbox_unpaired.png" @@ -16,6 +17,7 @@ class Plugin(DigitalBitboxPlugin, QtPluginBase): return DigitalBitbox_Handler(window) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py @@ -135,3 +135,10 @@ def trezor_validate_op_return_output_and_get_data(output: TxOutput) -> bytes: if output.value != 0: raise Exception(_("Amount for OP_RETURN output must be zero.")) return script[2:] + + +def only_hook_if_libraries_available(func): + def wrapper(self, *args, **kwargs): + if not self.libraries_available: return None + return func(self, *args, **kwargs) + return wrapper diff --git a/electrum/plugins/keepkey/qt.py b/electrum/plugins/keepkey/qt.py @@ -12,6 +12,7 @@ from electrum.util import PrintError, UserCancelled, bh2u from electrum.wallet import Wallet, Standard_Wallet from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available from .keepkey import KeepKeyPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC @@ -195,6 +196,7 @@ class QtPlugin(QtPluginBase): return QtHandler(window, self.pin_matrix_widget_class(), self.device) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return diff --git a/electrum/plugins/ledger/qt.py b/electrum/plugins/ledger/qt.py @@ -7,6 +7,7 @@ from electrum.gui.qt.util import * from .ledger import LedgerPlugin from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available class Plugin(LedgerPlugin, QtPluginBase): @@ -17,6 +18,7 @@ class Plugin(LedgerPlugin, QtPluginBase): return Ledger_Handler(window) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if type(wallet) is not Standard_Wallet: return diff --git a/electrum/plugins/safe_t/qt.py b/electrum/plugins/safe_t/qt.py @@ -12,6 +12,7 @@ from electrum.util import PrintError, UserCancelled, bh2u from electrum.wallet import Wallet, Standard_Wallet from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available from .safe_t import SafeTPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC @@ -71,6 +72,7 @@ class QtPlugin(QtPluginBase): return QtHandler(window, self.pin_matrix_widget_class(), self.device) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if len(addrs) != 1: return diff --git a/electrum/plugins/trezor/qt.py b/electrum/plugins/trezor/qt.py @@ -12,6 +12,7 @@ from electrum.util import PrintError, UserCancelled, bh2u from electrum.wallet import Wallet, Standard_Wallet from ..hw_wallet.qt import QtHandlerBase, QtPluginBase +from ..hw_wallet.plugin import only_hook_if_libraries_available from .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, RECOVERY_TYPE_SCRAMBLED_WORDS, RECOVERY_TYPE_MATRIX) @@ -166,6 +167,7 @@ class QtPlugin(QtPluginBase): return QtHandler(window, self.pin_matrix_widget_class(), self.device) @hook + @only_hook_if_libraries_available def receive_menu(self, menu, addrs, wallet): if len(addrs) != 1: return