electrum

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

commit 3f04520d0f0f5be690075cfa0030375ac2e1b5c6
parent b78cbcffd11364ed4651af1886d507b36bc1b013
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 18 Nov 2020 15:34:47 +0100

ledger: suppress traceback during device enumeration for locked device

ledger now gives an error if querying xpub while device is not (unlocked and in bitcoin app).
we do query the xpub however, to calc root fingerprint to be used as soft device id.

trace:

I | plugin.DeviceMgr | scanning devices...
D | util.profiler | DeviceMgr.scan_devices 3.4463
I | plugin.DeviceMgr | Registering <electrum.plugins.ledger.ledger.Ledger_Client object at 0x0000029DF6B08520>
E | gui.qt.installwizard.InstallWizard |
Traceback (most recent call last):
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 225, in checkDevice
    self.perform_hw1_preflight()
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 352, in run_in_hwd_thread
    return func()
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 219, in perform_hw1_preflight
    raise e
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 179, in perform_hw1_preflight
    firmwareInfo = self.dongleObject.getFirmwareVersion()
  File "...\Python38\site-packages\btchip\btchip.py", line 563, in getFirmwareVersion
    response = self.dongle.exchange(bytearray(apdu))
  File "...\Python38\site-packages\btchip\btchipComm.py", line 127, in exchange
    raise BTChipException("Invalid status %04x" % sw, sw)
btchip.btchipException.BTChipException: Exception : Invalid status 6700

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "...\electrum\electrum\base_wizard.py", line 317, in _choose_hw_device
    device_infos = devmgr.unpaired_device_infos(None, plugin, devices=scanned_devices,
  File "...\electrum\electrum\plugin.py", line 612, in unpaired_device_infos
    soft_device_id=client.get_soft_device_id(),
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 355, in run_in_hwd_thread
    return fut.result()
  File "...\Python38\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "...\Python38\lib\concurrent\futures\_base.py", line 388, in __get_result
    raise self._exception
  File "...\Python38\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 91, in get_soft_device_id
    self._soft_device_id = self.request_root_fingerprint_from_device()
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 352, in run_in_hwd_thread
    return func()
  File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 259, in request_root_fingerprint_from_device
    child_of_root_xpub = self.get_xpub("m/0'", xtype='standard')
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 352, in run_in_hwd_thread
    return func()
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 57, in catch_exception
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 111, in get_xpub
    self.checkDevice()
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 352, in run_in_hwd_thread
    return func()
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 228, in checkDevice
    raise UserFacingException(_("Device not in Bitcoin mode")) from e
electrum.util.UserFacingException: Device not in Bitcoin mode
W | gui.qt.installwizard.InstallWizard | error getting device infos for ledger: Device not in Bitcoin mode

Diffstat:
Melectrum/plugin.py | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/electrum/plugin.py b/electrum/plugin.py @@ -598,6 +598,10 @@ class DeviceMgr(ThreadJob): continue try: client = self.create_client(device, handler, plugin) + label = client.label() + is_initialized = client.is_initialized() + soft_device_id = client.get_soft_device_id() + model_name = client.device_model_name() except Exception as e: self.logger.error(f'failed to create client for {plugin.name} at {device.path}: {repr(e)}') if include_failing_clients: @@ -606,11 +610,11 @@ class DeviceMgr(ThreadJob): if not client: continue infos.append(DeviceInfo(device=device, - label=client.label(), - initialized=client.is_initialized(), + label=label, + initialized=is_initialized, plugin_name=plugin.name, - soft_device_id=client.get_soft_device_id(), - model_name=client.device_model_name())) + soft_device_id=soft_device_id, + model_name=model_name)) return infos