Example: using GET_MASTER_FINGERPRINT for Legacy Client to get the master public key fingerprint#10603
Merged
Merged
Conversation
SomberNight
reviewed
Apr 23, 2026
Comment on lines
+402
to
+405
| try: | ||
| return self.dongleObject.getMasterFingerprint() | ||
| except BTChipException as e: | ||
| if e.sw in (0x6d00, 0x6a80): # INS not supported / bad data |
Member
There was a problem hiding this comment.
if you assume a newer version of ledger_bitcoin, you need to declare it and bump the minimum:
at runtime:
electrum/electrum/plugins/ledger/ledger.py
Line 1219 in 7c433c5
at build time (for binaries):
electrum/contrib/requirements/requirements-hw.txt
Lines 16 to 18 in 7c433c5
(the pinned hashes, I will bump correspondingly)
6.35 | E | plugin.DeviceMgr | failed to create client for ledger at b'1-5:1.0': AttributeError("'btchip' object has no attribute 'getMasterFingerprint'")
Traceback (most recent call last):
File "/home/user/wspace/electrum/electrum/plugin.py", line 1267, in list_pairable_device_infos
soft_device_id = client.get_soft_device_id()
File "/home/user/wspace/electrum/electrum/plugin.py", line 1000, in wrapper
return run_in_hwd_thread(partial(func, *args, **kwargs))
File "/home/user/wspace/electrum/electrum/plugin.py", line 993, in run_in_hwd_thread
return fut.result()
~~~~~~~~~~^^
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/user/wspace/electrum/electrum/plugins/ledger/ledger.py", line 453, in get_soft_device_id
self._soft_device_id = self._get_master_fingerprint().hex()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/user/wspace/electrum/electrum/plugins/ledger/ledger.py", line 403, in _get_master_fingerprint
return self.dongleObject.getMasterFingerprint()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'btchip' object has no attribute 'getMasterFingerprint'
Contributor
Author
There was a problem hiding this comment.
@SomberNight , thank you for your feedback.
Sorry about that! The new ledger_bitcoin@v0.4.1 is indeed required, and I've just bumped the build-time and runtime versions in the lines you indicated.
Also tested with a venv from scratch locally.
SomberNight
added a commit
that referenced
this pull request
Apr 24, 2026
adapt Ledger_Client_Legacy to work with newer ledger bitcoin app manual merge of #10603
Member
|
merged in 5af40f4 Thanks for the patch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR provides an example of how new GET_MASTER_FINGERPRINT instruction of Ledger app-bitcoin can be adopted in a software wallet.
It overrides #10582 one.
Scope
Since the hardening introduced in LedgerHQ/app-bitcoin-legacy#297 (and in LedgerHQ/app-bitcoin-legacy#299 for
bitcoin_testnet_legacy), it is no longer possible to get the public key at the master level. Therefore, the newGET_MASTER_FINGERPRINTinstruction was introduced to replace it.The changes in this PR apply only to the legacy
app-bitcoinstarting from version2.4.11(and theLedger_Client_Legacypart). Specifically for Electrum, this only affects thebitcoin_testnet_legacyapp variant (Bitcoin Test Legacy), as there is no hardening applied to thebitcoin_legacyvariant (Bitcoin Legacy).For
app-bitcoin-newand the correspondingLedger_Client_New, everything is already handled well through theget_master_fingerprint()call.The new behavior is to first try the new instruction. If an error is returned (meaning the instruction does not exist in the app), it falls back to
getWalletPublicKey(). This ensures backward compatibility with app versions older than v2.4.11.Tests
This has been successfully tested as follows:
app-bitcoin(using them/84h/1h/0hpath corresponding totestnet), and connecting to it with the hardened version of the app.In the corresponding traces, it was observed that
INS_GET_WALLET_PUBLIC_KEYcommands withbip32Path.length = 0were effectively replaced byINS_GET_MASTER_FINGERPRINTcalls.