Merge bitcoindevkit/bdk-cli#383: refactor(key): share derivation between generate and restore
767592cc1d4a98248e466b0f4ce157fadddc25e7 refactor(key): share derivation between generate and restore (Ikeh Celestine Chukwudi)
Pull request description:
Fixes #382
`key generate` and `key restore` repeated 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 manual `fold` in `key generate` with the `Display` impl of `Mnemonic`, as `key restore` already did. `Display` joins 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 existing `key` tests cover both paths and pass unchanged.
ACKs for top commit:
tvpeter:
ACK
767592cc1d4a98248e466b0f4ce157fadddc25e7
Tree-SHA512: 91958fef2bebae78116d726d3676577e69a3349f5ef0e5ff10afd724acbbfd95490eaeb816aafc4e90879e9c37ebeeeedf94904e82072ace515a5b4043008bf0