mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
c3945bfd2bdoc: use derivehdkey in multisig tutorial (Sjors Provoost)3662e33669test: use derivehdkey in M-of-N multisig demo (Sjors Provoost)d9570f0838rpc: add derivehdkey (Sjors Provoost)62da9f9614wallet: add GetExtKey helper (Sjors Provoost)aaf1548475wallet: generalize GetActiveHDPubKeys helper (Sjors Provoost)3821452c4arefactor: add hardened derivation helper (Sjors Provoost)0ab61caafdrpc: ParsePathBIP32 helper (Sjors Provoost)e36c4b76e1util: reject out-of-range BIP32 keypath indices (Sjors Provoost)ba78c31a00fuzz: check ParseHDKeypath/WriteHDKeypath round-trip (Sjors Provoost)8cce969085Have ParseHDKeypath handle h derivation marker (Sjors Provoost)fc53077762test: move parse_hd_keypath test to bip32_tests (Sjors Provoost)dab525eb77key: add DeriveExtKey() helper (Sjors Provoost) Pull request description: Adds a `derivehdkey` RPC that returns an xpub, or optionally the xprv, at an arbitrary BIP32 path (with at least one hardened step), derived from a wallet HD key. The main use case is coordinating a multisig setup, where each participant shares an xpub derived at a hardened path (e.g. `m/87h/0h/0h`) distinct from their default single-signature descriptors. See the (updated) `doc/multisig-tutorial.md` and (updated) functional test to see how that workflow improves. The first commits are some helpful helpers: - _key: add DeriveExtKey() helper_ - performs the actual derivation - _test: move parse_hd_keypath test to bip32_tests_ - from `psbt_wallet_tests` - _Have ParseHDKeypath handle h derivation marker_ - _util: reject out-of-range BIP32 keypath indices_ - `ParseHDKeypath` would previously map overflowing values without `h` to hardened. - _fuzz: check ParseHDKeypath/WriteHDKeypath round-trip_ - _rpc: ParsePathBIP32 helper_ - _refactor: add hardened derivation helper_ - `HasHardenedDerivation()`, to enforce the "at least one hardened step" rule - _wallet: generalize GetActiveHDPubKeys helper_ - extracts code from `gethdkeys` which `derivehdkey` needs - _wallet: add GetExtKey helper_ - reconstruct an xprv from a wallet xpub (analog of `GetKey()`); behavior-preserving prep, also simplifies `gethdkeys`. Meat and potatoes: - _rpc: add derivehdkey_ - the RPC itself, plus the `UnusedKey` filter on `GetHDPubKeys` that drives key selection. - _test: use derivehdkey in M-of-N multisig demo_ - rewrites the functional multisig test to use the RPC and `<0;1>` syntax. - _doc: use derivehdkey in multisig tutorial_ - same for the prose tutorial. ACKs for top commit: pseudoramdom: code review ACKc3945bfd2bachow101: ACKc3945bfd2bw0xlt: That being the case, ACKc3945bfd2bTree-SHA512: 661f17c9bfe26017eb14c27ba7af37093387100d3baa25f5d29bba9c1aedc40d19afe1bdfc126a18d018857bb02f1fc84386f10b8f4f4b8e9d6f4b0691d9e302