Skip to content

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
aydencook03:watchonly-key-origin
Open

qml: allow entering key-origin info when importing a master key -> basic hardware wallet support#10588
aydencook03 wants to merge 6 commits intospesmilo:masterfrom
aydencook03:watchonly-key-origin

Conversation

@aydencook03
Copy link
Copy Markdown

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.

@aydencook03
Copy link
Copy Markdown
Author

new_UI

@aydencook03
Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant