electrum

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

commit 98d2ab5bd6f47961316c607f2a7ccd01fe38c472
parent cd199390e2d6376cdf9458c4a14906c564beea1c
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 17 Apr 2020 19:25:18 +0200

hww: fix HardwareClientBase not having reference to plugin

it was incorrectly documented that it did (previously only for some plugins)

Diffstat:
Melectrum/plugins/bitbox02/bitbox02.py | 6+++---
Melectrum/plugins/coldcard/coldcard.py | 5+++--
Melectrum/plugins/digitalbitbox/digitalbitbox.py | 2+-
Melectrum/plugins/hw_wallet/plugin.py | 4+++-
Melectrum/plugins/keepkey/clientbase.py | 1+
Melectrum/plugins/ledger/ledger.py | 6++++--
Melectrum/plugins/safe_t/clientbase.py | 1+
Melectrum/plugins/trezor/clientbase.py | 2+-
8 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py @@ -44,7 +44,8 @@ _logger = get_logger(__name__) class BitBox02Client(HardwareClientBase): # handler is a BitBox02_Handler, importing it would lead to a circular dependency - def __init__(self, handler: Any, device: Device, config: SimpleConfig): + def __init__(self, handler: Any, device: Device, config: SimpleConfig, *, plugin: HW_PluginBase): + HardwareClientBase.__init__(self, plugin=plugin) self.bitbox02_device = None self.handler = handler self.device_descriptor = device @@ -556,12 +557,11 @@ class BitBox02Plugin(HW_PluginBase): else: raise ImportError() - # handler is a BitBox02_Handler def create_client(self, device: Device, handler: Any) -> BitBox02Client: if not handler: self.handler = handler - return BitBox02Client(handler, device, self.config) + return BitBox02Client(handler, device, self.config, plugin=self) def setup_device( self, device_info: DeviceInfo, wizard: BaseWizard, purpose: int diff --git a/electrum/plugins/coldcard/coldcard.py b/electrum/plugins/coldcard/coldcard.py @@ -60,7 +60,8 @@ CKCC_SIMULATED_PID = CKCC_PID ^ 0x55aa class CKCCClient(HardwareClientBase): - def __init__(self, plugin, handler, dev_path, is_simulator=False): + def __init__(self, plugin, handler, dev_path, *, is_simulator=False): + HardwareClientBase.__init__(self, plugin=plugin) self.device = plugin.device self.handler = handler @@ -515,7 +516,7 @@ class ColdcardPlugin(HW_PluginBase): # the 'path' is unabiguous, so we'll use that. try: rv = CKCCClient(self, handler, device.path, - is_simulator=(device.product_key[1] == CKCC_SIMULATED_PID)) + is_simulator=(device.product_key[1] == CKCC_SIMULATED_PID)) return rv except: self.logger.info('late failure connecting to device?') diff --git a/electrum/plugins/digitalbitbox/digitalbitbox.py b/electrum/plugins/digitalbitbox/digitalbitbox.py @@ -66,7 +66,7 @@ CHANNEL_ID_KEY = 'comserverchannelid' class DigitalBitbox_Client(HardwareClientBase): def __init__(self, plugin, hidDevice): - self.plugin = plugin + HardwareClientBase.__init__(self, plugin=plugin) self.dbb_hid = hidDevice self.opened = True self.password = None diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py @@ -191,9 +191,11 @@ class HW_PluginBase(BasePlugin): class HardwareClientBase: - plugin: 'HW_PluginBase' handler = None # type: Optional['HardwareHandlerBase'] + def __init__(self, *, plugin: 'HW_PluginBase'): + self.plugin = plugin + def is_pairable(self) -> bool: raise NotImplementedError() diff --git a/electrum/plugins/keepkey/clientbase.py b/electrum/plugins/keepkey/clientbase.py @@ -103,6 +103,7 @@ class KeepKeyClientBase(HardwareClientBase, GuiMixin, Logger): def __init__(self, handler, plugin, proto): assert hasattr(self, 'tx_api') # ProtocolMixin already constructed? + HardwareClientBase.__init__(self, plugin=plugin) self.proto = proto self.device = plugin.device self.handler = handler diff --git a/electrum/plugins/ledger/ledger.py b/electrum/plugins/ledger/ledger.py @@ -62,7 +62,9 @@ def test_pin_unlocked(func): class Ledger_Client(HardwareClientBase): - def __init__(self, hidDevice, *, product_key: Tuple[int, int]): + def __init__(self, hidDevice, *, product_key: Tuple[int, int], + plugin: HW_PluginBase): + HardwareClientBase.__init__(self, plugin=plugin) self.dongleObject = btchip(hidDevice) self.preflightDone = False self._product_key = product_key @@ -602,7 +604,7 @@ class LedgerPlugin(HW_PluginBase): client = self.get_btchip_device(device) if client is not None: - client = Ledger_Client(client, product_key=device.product_key) + client = Ledger_Client(client, product_key=device.product_key, plugin=self) return client def setup_device(self, device_info, wizard, purpose): diff --git a/electrum/plugins/safe_t/clientbase.py b/electrum/plugins/safe_t/clientbase.py @@ -105,6 +105,7 @@ class SafeTClientBase(HardwareClientBase, GuiMixin, Logger): def __init__(self, handler, plugin, proto): assert hasattr(self, 'tx_api') # ProtocolMixin already constructed? + HardwareClientBase.__init__(self, plugin=plugin) self.proto = proto self.device = plugin.device self.handler = handler diff --git a/electrum/plugins/trezor/clientbase.py b/electrum/plugins/trezor/clientbase.py @@ -40,10 +40,10 @@ MESSAGES = { class TrezorClientBase(HardwareClientBase, Logger): def __init__(self, transport, handler, plugin): + HardwareClientBase.__init__(self, plugin=plugin) if plugin.is_outdated_fw_ignored(): TrezorClient.is_outdated = lambda *args, **kwargs: False self.client = TrezorClient(transport, ui=self) - self.plugin = plugin self.device = plugin.device self.handler = handler Logger.__init__(self)