Skip to content

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

Draft
Sjors wants to merge 12 commits intobitcoin:masterfrom
Sjors:2025/06/gethdkey
Draft

wallet: derivehdkey RPC to get xpub at arbitrary path#32784
Sjors wants to merge 12 commits intobitcoin:masterfrom
Sjors:2025/06/gethdkey

Conversation

@Sjors
Copy link
Copy Markdown
Member

@Sjors Sjors commented Jun 20, 2025

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.

Based on:

@DrahtBot DrahtBot changed the title wallet: derivehdkey RPC to get xpub at arbitrary path wallet: derivehdkey RPC to get xpub at arbitrary path Jun 20, 2025
@DrahtBot
Copy link
Copy Markdown
Contributor

DrahtBot commented Jun 20, 2025

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.

Type Reviewers
Concept ACK rkrux

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #bitcoin-core/gui/872 (Menu action to export a watchonly wallet by achow101)
  • #35092 (wallet: stop materializing skipped descriptor addresses after high-index detection by takeshikurosawaa)
  • #35069 (Refactor keypath parser by pythcoiner)
  • #34861 (wallet: Add importdescriptors interface by polespinasa)
  • #33392 (wallet, rpc: add UTXO set check and incremental rescan to importdescriptors by musaHaruna)
  • #32861 (Have createwalletdescriptor auto-detect an unused(KEY) by Sjors)
  • #32489 (wallet: Add exportwatchonlywallet RPC to export a watchonly version of a wallet by achow101)
  • #31668 (Added rescan option for import descriptors by saikiran57)

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:

  • # Get the activate wpkh() receive descriptor -> # Get the active wpkh() receive descriptor [“activate” is the wrong word here; the intended meaning is “active.”]

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • Parse(desc_str, keys, error, false) in src/wallet/rpc/wallet.cpp
  • WalletDescriptor(std::move(descs.at(0)), GetTime(), 0, 0, 0) in src/wallet/rpc/wallet.cpp

2026-05-01 11:28:58

@DrahtBot
Copy link
Copy Markdown
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.

Hints

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.

Comment thread src/rpc/util.h Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In util.h: “@params[in] path” → “@param[in] path” [Doxygen tag typo]

Comment thread doc/multisig-tutorial.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rkrux
Copy link
Copy Markdown
Contributor

rkrux commented Jul 18, 2025

Very nice, Concept ACK.
I will review this PR.

@Sjors Sjors force-pushed the 2025/06/gethdkey branch 2 times, most recently from 380a57f to 017fb68 Compare August 1, 2025 10:52
@Sjors
Copy link
Copy Markdown
Member Author

Sjors commented Jan 5, 2026

Rebased after #32821 landed and #29136 was rebased. Re-tested by having an LLM follow the tutorial.

@DrahtBot
Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/25052455086/job/73383604351
LLM reason (✨ experimental): CI failed because the CMake build errored while compiling src/wallet (bitcoin_wallet target), stopping with make/gmake exit code 2.

Hints

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.

@Sjors
Copy link
Copy Markdown
Member Author

Sjors commented Apr 28, 2026

I pushed an extra commit 9814b33 to pre-empt IWYU warnings (at least in Sjors#91, probably here too). That caused CI to pick up the latest master, which fails as expected. I'll push again after #29136 is updated.

@Sjors Sjors force-pushed the 2025/06/gethdkey branch from 9814b33 to d05788e Compare May 1, 2026 11:24
Sjors added 6 commits May 1, 2026 13:27
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.
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.
@Sjors Sjors force-pushed the 2025/06/gethdkey branch from d05788e to 2e6b696 Compare May 1, 2026 11:28
@Sjors
Copy link
Copy Markdown
Member Author

Sjors commented May 1, 2026

Rebased after #29136 updated and squashed 9814b33 IWYU fixup into the first commit.

@DrahtBot DrahtBot removed the CI failed label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants