Allows addhdkey to derive and import a BIP 32 master key from an English BIP 39 mnemonic and an optional ASCII passphrase.
Only the derived key is stored. Creating active descriptors and rescanning remain explicit steps.
Motivation
- Enable recovery and import workflows for an existing wallet from a mnemonic without first converting the seed phrase to an
xprvusing an external tool. - Reduce exposure of the mnemonic to additional software.
Changes
- Allow
addhdkeyto accept amnemonicas an alternative tohdkey, together with an optionalbip39_passphrase. - Support the English word list and ASCII-only passphrases.
- Validate the word count, word-list membership, and checksum.
- Store only the derived HD key in the wallet.
- Do not create active descriptors or initiate a blockchain rescan.
Tests
The following tests were run locally:
- Unit tests:
src/wallet/test/bip39_tests.cpp(build/bin/test_bitcoin --run_test=bip39_tests) - Fuzz targets:
bip39andbip39_validinsrc/wallet/test/fuzz/bip39.cpp(built and smoke-tested with empty input) - Functional tests:
test/functional/wallet_hd.py(build/test/functional/wallet_hd.py --portseed=5301) - Full CTest suite:
ctest --test-dir build --output-on-failure -j12(completed without failures;script_assets_testswas skipped)