Repository navigation
refactor(key): share derivation between generate and restore - #383
chukwudiikeh wants to merge 1 commit into
Conversation
|
@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. |
3ecf3b8 to
c7ed372
Compare
c7ed372 to
86cf70b
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
86cf70b to
a302315
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #383 +/- ##
==========================================
- Coverage 60.00% 59.96% -0.05%
==========================================
Files 25 25
Lines 4736 4726 -10
==========================================
- Hits 2842 2834 -8
+ Misses 1894 1892 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks @emma31-dev . I stacked it on purpose: #384 is built on top of this PR #382 first, then the #381 rename, so this one should land first. I've rebased #384 onto the current commit here so it only adds the rename on top. |
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.