Browse Source

hww: fix HardwareClientBase not having reference to plugin

it was incorrectly documented that it did (previously only for some plugins)
master
SomberNight 5 years ago
parent
commit
98d2ab5bd6
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/plugins/bitbox02/bitbox02.py
  2. 5
      electrum/plugins/coldcard/coldcard.py
  3. 2
      electrum/plugins/digitalbitbox/digitalbitbox.py
  4. 4
      electrum/plugins/hw_wallet/plugin.py
  5. 1
      electrum/plugins/keepkey/clientbase.py
  6. 6
      electrum/plugins/ledger/ledger.py
  7. 1
      electrum/plugins/safe_t/clientbase.py
  8. 2
      electrum/plugins/trezor/clientbase.py

6
electrum/plugins/bitbox02/bitbox02.py

@ -44,7 +44,8 @@ _logger = get_logger(__name__)
class BitBox02Client(HardwareClientBase): class BitBox02Client(HardwareClientBase):
# handler is a BitBox02_Handler, importing it would lead to a circular dependency # 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.bitbox02_device = None
self.handler = handler self.handler = handler
self.device_descriptor = device self.device_descriptor = device
@ -556,12 +557,11 @@ class BitBox02Plugin(HW_PluginBase):
else: else:
raise ImportError() raise ImportError()
# handler is a BitBox02_Handler # handler is a BitBox02_Handler
def create_client(self, device: Device, handler: Any) -> BitBox02Client: def create_client(self, device: Device, handler: Any) -> BitBox02Client:
if not handler: if not handler:
self.handler = handler self.handler = handler
return BitBox02Client(handler, device, self.config) return BitBox02Client(handler, device, self.config, plugin=self)
def setup_device( def setup_device(
self, device_info: DeviceInfo, wizard: BaseWizard, purpose: int self, device_info: DeviceInfo, wizard: BaseWizard, purpose: int

5
electrum/plugins/coldcard/coldcard.py

@ -60,7 +60,8 @@ CKCC_SIMULATED_PID = CKCC_PID ^ 0x55aa
class CKCCClient(HardwareClientBase): 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.device = plugin.device
self.handler = handler self.handler = handler
@ -515,7 +516,7 @@ class ColdcardPlugin(HW_PluginBase):
# the 'path' is unabiguous, so we'll use that. # the 'path' is unabiguous, so we'll use that.
try: try:
rv = CKCCClient(self, handler, device.path, 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 return rv
except: except:
self.logger.info('late failure connecting to device?') self.logger.info('late failure connecting to device?')

2
electrum/plugins/digitalbitbox/digitalbitbox.py

@ -66,7 +66,7 @@ CHANNEL_ID_KEY = 'comserverchannelid'
class DigitalBitbox_Client(HardwareClientBase): class DigitalBitbox_Client(HardwareClientBase):
def __init__(self, plugin, hidDevice): def __init__(self, plugin, hidDevice):
self.plugin = plugin HardwareClientBase.__init__(self, plugin=plugin)
self.dbb_hid = hidDevice self.dbb_hid = hidDevice
self.opened = True self.opened = True
self.password = None self.password = None

4
electrum/plugins/hw_wallet/plugin.py

@ -191,9 +191,11 @@ class HW_PluginBase(BasePlugin):
class HardwareClientBase: class HardwareClientBase:
plugin: 'HW_PluginBase'
handler = None # type: Optional['HardwareHandlerBase'] handler = None # type: Optional['HardwareHandlerBase']
def __init__(self, *, plugin: 'HW_PluginBase'):
self.plugin = plugin
def is_pairable(self) -> bool: def is_pairable(self) -> bool:
raise NotImplementedError() raise NotImplementedError()

1
electrum/plugins/keepkey/clientbase.py

@ -103,6 +103,7 @@ class KeepKeyClientBase(HardwareClientBase, GuiMixin, Logger):
def __init__(self, handler, plugin, proto): def __init__(self, handler, plugin, proto):
assert hasattr(self, 'tx_api') # ProtocolMixin already constructed? assert hasattr(self, 'tx_api') # ProtocolMixin already constructed?
HardwareClientBase.__init__(self, plugin=plugin)
self.proto = proto self.proto = proto
self.device = plugin.device self.device = plugin.device
self.handler = handler self.handler = handler

6
electrum/plugins/ledger/ledger.py

@ -62,7 +62,9 @@ def test_pin_unlocked(func):
class Ledger_Client(HardwareClientBase): 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.dongleObject = btchip(hidDevice)
self.preflightDone = False self.preflightDone = False
self._product_key = product_key self._product_key = product_key
@ -602,7 +604,7 @@ class LedgerPlugin(HW_PluginBase):
client = self.get_btchip_device(device) client = self.get_btchip_device(device)
if client is not None: 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 return client
def setup_device(self, device_info, wizard, purpose): def setup_device(self, device_info, wizard, purpose):

1
electrum/plugins/safe_t/clientbase.py

@ -105,6 +105,7 @@ class SafeTClientBase(HardwareClientBase, GuiMixin, Logger):
def __init__(self, handler, plugin, proto): def __init__(self, handler, plugin, proto):
assert hasattr(self, 'tx_api') # ProtocolMixin already constructed? assert hasattr(self, 'tx_api') # ProtocolMixin already constructed?
HardwareClientBase.__init__(self, plugin=plugin)
self.proto = proto self.proto = proto
self.device = plugin.device self.device = plugin.device
self.handler = handler self.handler = handler

2
electrum/plugins/trezor/clientbase.py

@ -40,10 +40,10 @@ MESSAGES = {
class TrezorClientBase(HardwareClientBase, Logger): class TrezorClientBase(HardwareClientBase, Logger):
def __init__(self, transport, handler, plugin): def __init__(self, transport, handler, plugin):
HardwareClientBase.__init__(self, plugin=plugin)
if plugin.is_outdated_fw_ignored(): if plugin.is_outdated_fw_ignored():
TrezorClient.is_outdated = lambda *args, **kwargs: False TrezorClient.is_outdated = lambda *args, **kwargs: False
self.client = TrezorClient(transport, ui=self) self.client = TrezorClient(transport, ui=self)
self.plugin = plugin
self.device = plugin.device self.device = plugin.device
self.handler = handler self.handler = handler
Logger.__init__(self) Logger.__init__(self)

Loading…
Cancel
Save