qml: allow entering key-origin info when importing a master key -> basic hardware wallet support#10588
Open
aydencook03 wants to merge 6 commits intospesmilo:masterfrom
Open
qml: allow entering key-origin info when importing a master key -> basic hardware wallet support#10588aydencook03 wants to merge 6 commits intospesmilo:masterfrom
aydencook03 wants to merge 6 commits intospesmilo:masterfrom
Conversation
Author
Author
|
The two fields are completely optional, and the default behavior is preserved if they're left blank. Also, they are only visible if the key that has been entered has depth > 1 and electrum can't infer the origin data. |
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.

When creating a watch-only wallet on mobile by pasting an xpub, Electrum calls root_fp_and_der_prefix_from_xkey() to recover the derivation path and master fingerprint. This works fine for depth-0 and depth-1 keys, but hardware wallets typically export at deeper paths (a Coldcard zpub, for example, is at m/84'/0'/0', depth 3). For keys at depth > 1, neither the master fingerprint nor the full derivation path can be read from the xpub, so they end up stored as null.
This matters because without key-origin metadata in the keystore, the PSBTs Electrum generates won't include it either, and hardware wallets that verify key-origin will reject signing.
This PR adds a key-origin section to the WCHaveMasterKey wizard screen in the QML GUI. When the user pastes a key that Electrum can't infer origin info for (depth > 1), two optional fields appear (derivation path and master fingerprint) so the user can supply them manually. The section is hidden entirely for depth <= 1 since Electrum already handles those automatically.
On the backend, a new verifyKeyOriginInfo slot does basic client-side validation (path structure and depth consistency with the xpub), and create_storage() in wizard.py passes the values through to keystore.add_key_origin() if provided. A masterKeyDepth slot is also exposed so the QML layer can check depth without duplicating the bip32 logic.
This is the minimum needed to support a basic hardware wallet signing loop on mobile: import an xpub, provide the derivation path and fingerprint shown on the device, and the resulting PSBTs will carry the key-origin data the device expects.