This commit is contained in:
SomberNight 2018-09-19 20:02:03 +02:00
parent 8caab35d90
commit f9a5f2e183
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
7 changed files with 23 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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