AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 19 Bitcoin

Merge bitcoin/bitcoin#35436: wallet: Add addHDkey interface

Public commit record

What the developer wrote

Authored by merge-script

91/100 · Strong
Merge bitcoin/bitcoin#35436: wallet: Add addHDkey interface

1bb5820b4411dfbc0ade5fada39d1a4af46dfa78 wallet: Add addhdkey interface (pseudoramdom)
82867073d6c3f3d160a7036ff3d7caa71c71651a wallet: Use WalletError for AddHDKey failures (pseudoramdom)
f8769fc0b12459eedc1bd8e37001b7fccd12b33f wallet: Move addhdkey logic into CWallet (pseudoramdom)
e1a2b25d6c3b1ed6d693d328d1aa5efaceb69c55 test: expand addhdkey coverage for locked wallet and bad key (Sjors Provoost)

Pull request description:

This PR adds a wallet interface for `addhdkey`.

The motivation is same as #34861 - while we have `addhdkey` RPC, Bitcoin Core GUI does not use the RPC interface. Having a dedicated wallet interface is helpful for GUI when performing multisig setup. When used in tandem with a similar interface for `derivehdkey` (#32784), the GUI can produce a shareable xpub during multisig setup.

Key changes:
- Move the wallet logic from the `addhdkey` RPC into `CWallet::AddHDKey()`.
- Update `addhdkey` RPC to call `CWallet::AddHDKey()` while keeping RPC-specific argument parsing
- Introduce `WalletError`, a generic wallet-layer error type carrying a machine-readable `WalletErrorCode` and a translated user-facing message.
- Update `addhdkey` RPC to use the above wallet helper. The RPC also exposes the master fingerprint in hex as `fingerprint` field.
- Add `interfaces::Wallet::addHDKey()`, which generates and adds a new HD key and returns the master xpub.
- Add unit test coverage for `interfaces::Wallet::addHDKey()`.

ACKs for top commit:
davidgumberg:
crreACK 1bb5820
achow101:
ACK 1bb5820b4411dfbc0ade5fada39d1a4af46dfa78
polespinasa:
ACK 1bb5820b4411dfbc0ade5fada39d1a4af46dfa78
w0xlt:
ACK 1bb5820b4411dfbc0ade5fada39d1a4af46dfa78

Tree-SHA512: e45170c803faae71f5a088bdae92ee1664c2ae17d4447ed0192a1117cd39464a6d7f8ee84e91afdd0aefe47cd1c1f869e89e0c4d9a9ff9dbed1b0d970867224b
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit refactors how Bitcoin Core wallets add new HD (hierarchical deterministic) keys. It moves the existing addhdkey logic from the RPC layer into a reusable CWallet method and exposes it through the wallet interface used by the GUI. The change is primarily a code-organization improvement to support future GUI multisig setup. It does not appear to introduce a security vulnerability; rather, it adds clearer error handling and tests for locked wallets and invalid keys.

Recommended action

No security action required. Treat as a normal feature/refactor review. Monitor follow-up PRs that will use this interface in the GUI for multisig setup.

Security signals we found

01

Refactor of existing wallet key-management RPC into reusable interface

02

Adds explicit WalletError with UnlockNeeded code for locked-wallet failures

03

Adds functional test for locked-wallet rejection and unit test for malformed key

04

No new entropy source or key generation algorithm introduced

05

No new network, RPC, or file-system attack surface added

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.