HomePhabricator

[electrum] never suggest the same proof master key or delegation key twice

Description

[electrum] never suggest the same proof master key or delegation key twice

Summary:
Previously we would always suggest the auxiliary key with index 0 as the proof master key, and open a key generation widget which shows index 1 by default when generating a delegation.

Store a counter/index as wallet data and increment it whenever a new auxiliary key is shown, so that we always suggest a new key. Users can still find their old keys by opening the Auxiliary keys tool and decrementing the value, but we will never suggest using an old one.

Bump the range of the index widget to allow the full range of indices, as per bip 32.

Test Plan:
Open a wallet, open the proof editor dialog, close it and reopen a new proof editor dialog, check that the master key is different.
Then open a delegation editor dialog, click "generate key" and check that it opens an auxiliary key dialog with index 2 (0 and 1 were used for the two proofs). Increment the indexto 3, close the delegation dialog.
Then open the "Auxiliary keys" dialog via the "Wallet" menu, check that the index is now 4.

Close the wallet, reopen it, check that the index is now 5.

Set the index to 2147483647 (MAX value), close the wallet, reopen it and check that opening the auxiliary keys tool does not cause an overflow error (and the index is now stuck at 2147483647)

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
PiRKAuthored on Oct 5 2023, 09:59
PiRKPushed on Oct 5 2023, 11:48
Reviewer
Restricted Project
Differential Revision
D14603: [electrum] never suggest the same proof master key or delegation key twice
Parents
rABCd1649bc29290: [electrum] minor improvements to proof editor
Branches
Unknown
Tags
Unknown