wallet: derivehdkey RPC to get xpub at arbitrary path #32784

pull Sjors wants to merge 12 commits into bitcoin:master from Sjors:2025/06/gethdkey changing 20 files +751 −88
  1. Sjors commented at 11:04 am on June 20, 2025: member

    Based on #29136.

    Given a (blank) wallet with an unused(KEY) descriptor, derivehdkey "m/87h/0h/0h" gets the xpub or xpriv at any given path.

    This is particularly useful for multisig setup where it’s not desirable to use our default derivations (e.g. 44h).

    I updated the multisig tutorial and the functional test.

  2. descriptor: Add unused(KEY) descriptor
    unused() descriptors do not have scriptPubKeys. Instead, the wallet uses
    them to store keys without having any scripts to watch for.
    10b677530e
  3. test: Simple test for importing unused(KEY) 92849bdd9b
  4. wallet: Add addhdkey RPC 0d24f0af7a
  5. wallet, rpc: Disallow import of unused() if key already exists cba3bcb6a7
  6. wallet, rpc: Disallow importing unused() to wallets without privkeys 6100108594
  7. DrahtBot renamed this:
    wallet: derivehdkey RPC to get xpub at arbitrary path
    wallet: derivehdkey RPC to get xpub at arbitrary path
    on Jun 20, 2025
  8. DrahtBot added the label Wallet on Jun 20, 2025
  9. DrahtBot commented at 11:04 am on June 20, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32784.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/872 (Menu action to export a watchonly wallet by achow101)
    • #32821 (rpc: Handle -named argument parsing where Base64 encoding is used by zaidmstrr)
    • #32652 (wallet: add codex32 argument to addhdkey by roconnor-blockstream)
    • #32489 (wallet: Add exportwatchonlywallet RPC to export a watchonly version of a wallet by achow101)
    • #30341 (WIP: Permit Combiner to strip bip32_deriv information by willcl-ark)
    • #30243 (descriptors: taproot partial descriptors by Eunovo)
    • #28333 (wallet: Construct ScriptPubKeyMans with all data rather than loaded progressively by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • addressesd -> addresses [extra “d” makes “addresses” misspelled]

    drahtbot_id_4_m

  10. DrahtBot added the label CI failed on Jun 20, 2025
  11. DrahtBot commented at 11:47 am on June 20, 2025: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin/bitcoin/runs/44475268764 LLM reason (✨ experimental): The CI failure is caused by errors from the lint check ‘py_lint’, specifically due to unused imports flagged by ruff.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  12. Sjors force-pushed on Jun 20, 2025
  13. Sjors force-pushed on Jun 20, 2025
  14. Sjors force-pushed on Jun 20, 2025
  15. DrahtBot removed the label CI failed on Jun 20, 2025
  16. rpc: add DeriveExtKey() helper e4200216e9
  17. Have ParseHDKeypath handle h derivation marker 8375f773d7
  18. rpc: ParsePathBIP32 helper 43c9ce3fe2
  19. rpc: add derivehdkey 6b63a8a4fb
  20. test: use derivehdkey in M-of-N multisig demo
    Use derivehdkey instead of extracting each participant xpub (and derivation info) from  the listdescriptors output.
    
    Additionally use the new <0;1> descriptor syntax.
    
    Finally this commits adds a few debug log lines, and expand the explanation for why we use m/44h/1h/0h.
    ea37245f09
  21. in src/rpc/util.h:156 in 30d5e5ccf7 outdated
    151@@ -152,6 +152,14 @@ std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);
    152 /** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */
    153 std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider, const bool expand_priv = false);
    154 
    155+//! Get extended key and origin info for a given path
    156+//! @params[in] path The BIP 32 path
    


    DrahtBot commented at 9:41 am on June 25, 2025:
    In util.h: “@params[in] path” → “@param[in] path” [Doxygen tag typo]
    
  22. Sjors force-pushed on Jun 26, 2025
  23. rpc: Handle -named argument parsing where Base64 encoding is used 22cb00e59b
  24. doc: use derivehdkey in multisig tutorial
    Use derivehdkey instead of extracting each participant xpub
    from  the listdescriptors output.
    
    Additionally use the new <0;1> descriptor syntax.
    
    Also use bitcoin rpc instead of bitcoin-cli.
    35eec44491
  25. Sjors force-pushed on Jun 27, 2025


Sjors DrahtBot

Labels
Wallet


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-06-28 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me