#36070 wallet: Add deriveHDKey interface
https://github.com/bitcoin/bitcoin/pull/36070 · · +163/-55 in 7 files, 3 commits · labels: Wallet
Goal
- Allow the GUI to derive shareable extended public keys from an HD seed
- Unblock multisig setup workflows in the GUI without relying on RPC
This PR moves HD key derivation logic out of the derivehdkey RPC into CWallet::DeriveHDKey and exposes it through interfaces::Wallet::deriveHDKey. It returns derived neutered public keys (xpubs) and key origin metadata without exposing private keys across the interface boundary. Unit tests and functional test updates are included.
Problem: The derivehdkey RPC allows deriving child keys at arbitrary paths, but the GUI does not communicate via RPC and cannot access this functionality. This blocks GUI multisig setup workflows from deriving shareable xpubs from an added HD seed.
Category: Wallet (#26 of 84)
P2 · unblocks #35645
- P2 because it unblocks multisig setup workflows in the GUI tracked in #35645
- Enables users to derive shareable xpubs in the GUI without duplicating sensitive derivation logic
P2 because it unblocks a key component of the GUI Multisig Wizard project tracked in #35645. While adding an interface method is internal plumbing, it directly enables users to generate and share multisig xpubs in the GUI without duplicating sensitive key derivation logic.
Membership: Implements CWallet::DeriveHDKey, updates wallet RPC derivehdkey, and adds wallet unit tests and functional tests.
Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 2
Reviewability: Ready
- Ready for review
The PR has active CI, no merge conflicts, and the author actively updates the branch following review suggestions.
Author status: active
Open concerns:
- Whether collapsing derivation error codes in derivehdkey RPC from -8/-5 to -4 is an acceptable change for an RPC shipping in v32 (raised by pseudoramdom and polespinasa)
- Suggested commit reorganization to separate code extraction, error code changes, and interface addition for reviewability (raised by polespinasa)
Resolved concerns:
- Removing unreachable dead code in RPC unlock checking (raised by jeanpablojp and polespinasa)
- Consolidating SelectHDKey into CWallet::DeriveHDKey rather than having a duplicate RPC helper (raised by achow101)
- Tightening unit tests to assert derivation against the wallet's actual active key rather than trivial property checks (raised by jeanpablojp)
Agreement: Mild
- Concept approval to unblock GUI multisig workflows (polespinasa, jeanpablojp, pseudoramdom)
- Concern about changing RPC error codes on derivehdkey before release (pseudoramdom, polespinasa)
- Suggested reordering commits to isolate error code modifications (polespinasa)
Mild: Concept accepted, but open discussion remains on derivehdkey RPC error code compatibility
Multiple reviewers have Concept ACKed the change to support GUI multisig setup, but there is an open question about whether altering RPC error codes from -8/-5 to -4 introduces an unwanted contract change.
- polespinasa, jeanpablojp, pseudoramdom Concept ACKed
- achow101 suggested consolidating SelectHDKey directly into DeriveHDKey, which was implemented
- pseudoramdom: 'I\'m not sure if we\'re okay with changing the error contract since derivehdkey will ship in v32'
- polespinasa suggested a four-step commit reordering to isolate the error code changes
Review verdicts (DrahtBot): 0
- Concept ACK: polespinasa, jeanpablojp, pseudoramdom
Dependencies
Enables:
- #35645 (Multisig Wizard tracking issue)
Files
52 lines under test/bench/ci.
- src/wallet/wallet.cpp +97/-0
- src/wallet/rpc/wallet.cpp +5/-48
- src/wallet/test/wallet_interfaces_tests.cpp +38/-0
- test/functional/wallet_derivehdkey.py +7/-7
- src/wallet/interfaces.cpp +7/-0
- src/wallet/wallet.h +5/-0
- src/interfaces/wallet.h +4/-0
Card
This PR moves HD key derivation logic into CWallet::DeriveHDKey and adds a corresponding interfaces::Wallet method so that the GUI can derive xpubs without using RPC. It directly unblocks the deriveHDKey step in the Multisig Wizard tracking project (#35645). Concept support is strong from multiple contributors, though discussion remains open on whether changing error codes in the derivehdkey RPC is acceptable. The code is ready for review and actively maintained.