HomePhabricator

[electrum] detect the master private key when loading a proof

Description

[electrum] detect the master private key when loading a proof

Summary:
When loading a proof in the wallet that created it, if the master key is one the auxiliary private keys, we can find the private key from the deserialized public key instead of making the user paste the key.

This used to work with the assumption that we always use index 0 to derive the key for proofs. It is broken after D14603 which broke this assumption: the program now does not necessarily suggests key from index 0 when the user generates a second proof or uses keys for other purposes (delegations...)

Fix it by scanning up to 20 recently used auxiliary keys.

Introduce a StorageKeys class to avoid repeating (and possibly mistyping) the storage keys and their default values.

Test Plan:
Create a skeleton proof, save it to file or copy the hex to the clipboard.
Close the wallet, reopen the same wallet, open the proof editor, load the proof and check that the master key (WIF) is correctly filled and no warning dialog is displayed.

Reviewers: #bitcoin_abc, bytesofman, Fabien

Reviewed By: #bitcoin_abc, bytesofman, Fabien

Subscribers: bytesofman

Differential Revision: https://reviews.bitcoinabc.org/D14726

Details

Provenance
PiRKAuthored on Nov 2 2023, 09:03
PiRKPushed on Nov 3 2023, 16:28
Reviewer
Restricted Project
Differential Revision
D14726: [electrum] detect the master private key when loading a proof
Parents
rABC596deff98300: [electrum] clear the wallet password from memory when no longer needed
Branches
Unknown
Tags
Unknown