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
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
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:

  • #33874 (wallet: refactor ProcessDescriptorImport by naiyoma)
  • #33392 (wallet, rpc: add UTXO set check and incremental rescan to importdescriptors by musaHaruna)
  • #33008 (wallet: support bip388 policy with external signer by Sjors)
  • #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 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-02-02 15:38:12

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

src/rpc/util.h Outdated
Copy link
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]

Copy link
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
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
Member Author

Sjors commented Sep 26, 2025

(will rebase this later)

@Sjors Sjors force-pushed the 2025/06/gethdkey branch from 017fb68 to 2d40e1e Compare January 5, 2026 04:05
@Sjors
Copy link
Member Author

Sjors commented Jan 5, 2026

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

Sjors added 6 commits February 2, 2026 16:32
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.
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