Repository navigation
refactor(key): share derivation between generate and restore - #383
Open
chukwudiikeh wants to merge 1 commit into
Open
chukwudiikeh wants to merge 1 commit into
chukwudiikeh wants to merge 1 commit into
Conversation
Contributor
Author
|
@vadim-anfv @tvpeter this is the follow-up from issue #373, ready for review whenever you have time. No behaviour change the existing key tests cover both paths. |
chukwudiikeh
force-pushed
the
refactor/key-shared-derivation
branch
from
November 11, 2026 15:15
3ecf3b8 to
c7ed372
Compare
GenerateKeyCommand and RestoreKeyCommand repeated the same steps to derive the master key from a mnemonic, and the duplication is how bitcoindevkit#372 happened. Move them into key_from_mnemonic, called by both, and use the Display impl of Mnemonic instead of the manual fold, which gives the same output. Fixes bitcoindevkit#382
chukwudiikeh
force-pushed
the
refactor/key-shared-derivation
branch
from
November 11, 2026 15:33
c7ed372 to
86cf70b
Compare
This branch has not been deployed
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.
Fixes #382
key generateandkey restorerepeated the same steps to derive the master key from a mnemonic and passphrase, differing only in where the mnemonic comes from. That duplication is how issue #372 happened: one copy dropped the passphrase.This PR moves the shared steps into
key_from_mnemonic, which both commands call, and replaces the manualfoldinkey generatewith theDisplayimpl ofMnemonic, askey restorealready did.Displayjoins the words with single spaces, the same output as the fold; I compared generate and restore output for 40 mnemonics (12 and 24 words) and all matched.No behaviour change. The existingkeytests cover both paths and pass unchanged.