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 on the PR head (RelWithDebInfo build with -DBUILD_GUI=ON -DWITH_ZMQ=ON -DWITH_USDT=ON):
- Unit tests: full CTest suite (
ctest --test-dir build -j16) — 372/372 passed, 0 failed.script_assets_testswas skipped as it requires an external asset file. Includes the newsrc/wallet/test/bip39_tests.cpp(build/bin/test_bitcoin --run_test=bip39_tests). - Functional tests: full suite (
build/test/functional/test_runner.py -j12) — 280 passed, 0 failed, 16 skipped for environment reasons (USDT tests need root/BPF, backwards-compatibility tests need previous-release binaries, IPC mining needs a multiprocess build). Includestest/functional/wallet_hd.py. - Fuzz targets:
bip39andbip39_validinsrc/wallet/test/fuzz/bip39.cpp, built with-DBUILD_FUZZ_BINARY=ON -DBUILD_FOR_FUZZING=ONand run against seed inputs (official test vectors, unknown words, empty input, random bytes).