Browse Source

hw DeviceMgr: don't filter already paired devices in wizard

Related to prev commit: multiple (compatible) keystores can now match
with the same HardwareClientBase, so we might as well also allow
reusing existing Clients for the wizard.
master
SomberNight 3 years ago
parent
commit
a4276102f2
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/base_wizard.py
  2. 19
      electrum/plugin.py
  3. 2
      run_electrum

6
electrum/base_wizard.py

@ -313,9 +313,9 @@ class BaseWizard(Logger):
continue
# see if plugin recognizes 'scanned_devices'
try:
# FIXME: side-effect: unpaired_device_info sets client.handler
device_infos = devmgr.unpaired_device_infos(None, plugin, devices=scanned_devices,
include_failing_clients=True)
# FIXME: side-effect: this sets client.handler
device_infos = devmgr.list_pairable_device_infos(
handler=None, plugin=plugin, devices=scanned_devices, include_failing_clients=True)
except HardwarePluginLibraryUnavailable as e:
failed_getting_device_infos(name, e)
continue

19
electrum/plugin.py

@ -585,17 +585,22 @@ class DeviceMgr(ThreadJob):
'its seed (and passphrase, if any). Otherwise all bitcoins you '
'receive will be unspendable.').format(plugin.device))
def unpaired_device_infos(self, handler: Optional['HardwareHandlerBase'], plugin: 'HW_PluginBase',
devices: Sequence['Device'] = None,
include_failing_clients=False) -> List['DeviceInfo']:
'''Returns a list of DeviceInfo objects: one for each connected,
unpaired device accepted by the plugin.'''
def list_pairable_device_infos(
self,
*,
handler: Optional['HardwareHandlerBase'],
plugin: 'HW_PluginBase',
devices: Sequence['Device'] = None,
include_failing_clients: bool = False,
) -> List['DeviceInfo']:
"""Returns a list of DeviceInfo objects: one for each connected device accepted by the plugin.
Already paired devices are also included, as it is okay to reuse them.
"""
if not plugin.libraries_available:
message = plugin.get_library_not_available_message()
raise HardwarePluginLibraryUnavailable(message)
if devices is None:
devices = self.scan_devices()
devices = [dev for dev in devices if not self.pairing_code_by_id(dev.id_)]
infos = []
for device in devices:
if not plugin.can_recognize_device(device):
@ -629,7 +634,7 @@ class DeviceMgr(ThreadJob):
# ideally this should not be called from the GUI thread...
# assert handler.get_gui_thread() != threading.current_thread(), 'must not be called from GUI thread'
while True:
infos = self.unpaired_device_infos(handler, plugin, devices)
infos = self.list_pairable_device_infos(handler=handler, plugin=plugin, devices=devices)
if infos:
break
if not allow_user_interaction:

2
run_electrum

@ -193,7 +193,7 @@ def get_connected_hw_devices(plugins: 'Plugins'):
_logger.error(f"{name}: error during plugin init: {repr(e)}")
continue
try:
u = devmgr.unpaired_device_infos(None, plugin)
u = devmgr.list_pairable_device_infos(handler=None, plugin=plugin)
except Exception as e:
_logger.error(f'error getting device infos for {name}: {repr(e)}')
continue

Loading…
Cancel
Save