Revives #22341 (marked "up for grabs").
Add gethdkey RPC to derive an extended key at any BIP 32 path from the wallet's active HD key.
This enables exporting xpubs/xprvs for external setups (e.g., BIP 87 multisig) without modifying the wallet's keypool.
$ bitcoin-cli gethdkey "m/87'/0'/0'"
{
"xpub": "xpub6...",
"fingerprint": "1a2b3c4d",
"origin": "[1a2b3c4d/87'/0'/0']"
}
$ bitcoin-cli gethdkey "m/87'/0'/0'" '{"private": true}'
{
"xpub": "xpub6...",
"xprv": "xprv9...",
..
}
Use case: Users setting up multisig (e.g., with hardware wallets or other software) need xpubs at specific derivation paths. Currently this there is no way to extract a specific path from wallets in Bitcoin Core.
Design: Intentionally simple, only exports key info. To sign with derived keys, users import the returned xprv via importdescriptors. This keeps all signing through the normal keypool mechanism.