Ledger: Handle automatic lock better
See original GitHub issueWhen a Ledger Nano S was unlocked and then went into the auto lock, EC does not react to it well. Starting a new EC instance with a Ledger in this state connected results in the following:
Traceback (most recent call last):
File "/home/user/src/electrum/gui/qt/util.py", line 691, in run
result = task.task()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 549, in get_client
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
File "/home/user/src/electrum/lib/plugins.py", line 718, in client_for_keystore
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
File "/home/user/src/electrum/lib/plugins.py", line 748, in force_pair_xpub
client_xpub = client.get_xpub(derivation, xtype)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 78, in catch_exception
return func(self, *args, **kwargs)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 88, in get_xpub
self.checkDevice()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 208, in checkDevice
raise e
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 204, in checkDevice
self.perform_hw1_preflight()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 199, in perform_hw1_preflight
raise e
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 185, in perform_hw1_preflight
raise e
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 181, in perform_hw1_preflight
self.dongleObject.getWalletPublicKey("44'/145'/0'/0/0", showOnScreen=False, cashAddr=True)
File "/home/user/.local/lib/python3.5/site-packages/btchip/btchip.py", line 124, in getWalletPublicKey
response = self.dongle.exchange(bytearray(apdu))
File "/home/user/.local/lib/python3.5/site-packages/btchip/btchipComm.py", line 127, in exchange
raise BTChipException("Invalid status %04x" % sw, sw)
btchip.btchipException.BTChipException: Exception : Invalid status 6f04
After this, when I click the Ledger icon to retry the connection I get this:
Traceback (most recent call last):
File "/home/user/src/electrum/gui/qt/main_window.py", line 82, in onPress
self.func()
File "/home/user/src/electrum/plugins/hw_wallet/qt.py", line 230, in show_settings_dialog
device_id = self.choose_device(window, keystore)
File "/home/user/src/electrum/plugins/hw_wallet/qt.py", line 223, in choose_device
info = self.device_manager().select_device(self, keystore.handler, keystore)
File "/home/user/src/electrum/lib/plugins.py", line 786, in select_device
infos = self.unpaired_device_infos(handler, plugin, devices)
File "/home/user/src/electrum/lib/plugins.py", line 775, in unpaired_device_infos
client = self.create_client(device, handler, plugin)
File "/home/user/src/electrum/lib/plugins.py", line 651, in create_client
client = plugin.create_client(device, handler)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 522, in create_client
client = self.get_btchip_device(device)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 515, in get_btchip_device
dev.open_path(device.path)
File "hid.pyx", line 72, in hid.device.open_path
OSError: open failed
Seems that the device was not properly released and can’t be reopened. After restarting EC I then get the following:
Traceback (most recent call last):
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 149, in perform_hw1_preflight
firmwareInfo = self.dongleObject.getFirmwareVersion()
File "/home/user/.local/lib/python3.5/site-packages/btchip/btchip.py", line 561, in getFirmwareVersion
response = self.dongle.exchange(bytearray(apdu))
File "/home/user/.local/lib/python3.5/site-packages/btchip/btchipComm.py", line 127, in exchange
raise BTChipException("Invalid status %04x" % sw, sw)
btchip.btchipException.BTChipException: Exception : Invalid status 6faa
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/src/electrum/gui/qt/util.py", line 691, in run
result = task.task()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 549, in get_client
client = devmgr.client_for_keystore(self, handler, keystore, force_pair)
File "/home/user/src/electrum/lib/plugins.py", line 718, in client_for_keystore
client = self.force_pair_xpub(plugin, handler, info, xpub, derivation, devices)
File "/home/user/src/electrum/lib/plugins.py", line 748, in force_pair_xpub
client_xpub = client.get_xpub(derivation, xtype)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 78, in catch_exception
return func(self, *args, **kwargs)
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 88, in get_xpub
self.checkDevice()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 204, in checkDevice
self.perform_hw1_preflight()
File "/home/user/src/electrum/plugins/ledger/ledger.py", line 192, in perform_hw1_preflight
raise Exception("Dongle is temporarily locked - please unplug it and replug it again")
Exception: Dongle is temporarily locked - please unplug it and replug it again
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Set PIN lock and power off - Ledger Support
Set PIN lock or auto-power off to automatically lock or shutdown your Ledger Nano X device after a period of inactivity.
Read more >Ledger locks during transaction creation due to screensaver #79
The screensaver should not lock during transaction creation, this is not something that the user should have to manually increase. This was ...
Read more >The Advantages of Pushbutton Locks - Locksmith Ledger
With the more sophisticated systems, homeowners can get notifications ... Lever handle on both inside and outside; Auto-locking with Passage ...
Read more >Ledger Nano X Hardware Wallet Setup Guide (Latest Version ...
00:00 Intro 00:43 Unboxing01:12 Download Ledger Live App02:38 Launch ... Set Password/ Auto Lock for Ledger Live 20:24 Buy Bitcoin, Ethereum, ...
Read more >User Manual Ledger Nano X Certification - FCC Report
to manage the battery and Bluetooth, and to access device settings. ... If you've enabled auto-lock your device will show bouncing Ledger logos...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No worries, I will try to fix these. I am opening these to remind me.
So, first I’m going to use inspection to determine whether btchip-python supports CashAddr like this:
This way we do not have to actually call
getWalletPublicKey
inperform_hw1_preflight
.