Skip to content

wallet, rpc: Add analyzedescriptor for multisig setups - #36885

Open
pablomartin4btc wants to merge 13 commits into
bitcoin:masterfrom
pablomartin4btc:analyze-descriptor
Open

pablomartin4btc wants to merge 13 commits into
bitcoin:masterfrom
pablomartin4btc:analyze-descriptor

Conversation

@pablomartin4btc

@pablomartin4btc pablomartin4btc commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Part of the multisig setup work tracked in #35645. Based on #35918 (the first 3 commits).

Before importing a multisig descriptor received from a coordinator, each participant needs to check that it is the setup they agreed on: a k-of-n where any k cosigners can spend and nothing else can, that their own key is in it, and that they all derived the same first addresses (receive and change). Today nothing in Core reports what a descriptor commits to, so tools had to parse the descriptor string by hand, as the multisig wizard in #36325 (now closed) did.

This PR adds that check in three layers:

  1. Inspection (commits by w0xlt, with small changes listed below): GetKeyInfo(), GetKeyInventory() and GetPolicy() describe a parsed descriptor's key expressions, where each key is used, and how they combine. getdescriptorinfo gains a verbose option that returns them as keys and policy.
  2. Multisig analysis, no wallet: AnalyzeDescriptor() tells whether a descriptor is a recognized k-of-n setup, and if not, why. getdescriptorinfo verbose returns it as analysis, so it works even with -disablewallet.
  3. Wallet part: interfaces::Wallet::analyzeDescriptor (for the GUI) and the analyzedescriptor wallet RPC add which keys the wallet holds, whether it can sign, and the first address of each path (receive and change). They accept any descriptor, single-sig included; analysis.recognized tells whether it is a recognized k-of-n.

Recognized setups are wsh(multi)/wsh(sortedmulti), and tr(K,multi_a)/tr(K,sortedmulti_a) with a single leaf, where K is the BIP 341 NUMS point or a musig() of at least k distinct cosigners. Every cosigner must be an extended key other than the NUMS point, with an unhardened ranged derivation that can derive addresses, no musig() participant may need a hardened derivation step, and no two cosigners or participants may be found to be the same key. Anything else is still analyzed and returned, with recognized: false and the list of issues: the analysis warns, it never refuses a descriptor.

Example, run by one of the three cosigners:

$ bitcoin-cli -rpcwallet=alice analyzedescriptor "wsh(sortedmulti(2,[a1b2c3d4/48h/1h/0h/2h]tpub.../<0;1>/*,...))"
{
  "keys": [
    { "role": "ecdsa", "type": "bip32", "xpub": "tpub...", "derivation": "/0/*",
      "origin": { "master_fingerprint": "a1b2c3d4", "path": "m/48h/1h/0h/2h" }, "wallet": "mine" },
    { ..., "wallet": "not_mine" },
    { ..., "wallet": "not_mine" }
  ],
  "analysis": { "recognized": true, "shape": "wsh_multi", "sorted": true, "threshold": 2, "cosigners": [0, 1, 2], "issues": [] },
  "can_sign": true,
  "first_addresses": ["bcrt1q...", "bcrt1q..."],
  "hasprivatekeys": false
}

A locked wallet is not an error: a cosigner key with a hardened origin path can't be checked without the private key, so it is reported as "unknown", and can_sign is left out unless another key is already known to be the wallet's. This holds even when the wallet also has that key without its private key (e.g. an imported watch-only copy of its own xpub). "unknown" only appears when the wallet is locked, so the caller can always ask the user to unlock and retry. Everything else (analysis, first_addresses) is still returned. Only the candidate private key is decrypted, and none when the key is one of the wallet's HD keys itself.

A plain public key, as getaddressinfo or createmultisig use, is matched the same way through its origin: the one in the descriptor, or the one the wallet recorded when it derived the key (read with the new DescriptorScriptPubKeyMan::GetPubKeyOrigin(), which needs no private key). A plain public key the wallet has but can't sign for (from an imported watch-only descriptor, or another cosigner's key in a multisig it imported) is watch_only. Keys the wallet holds only as musig() participants are matched too, although gethdkeys doesn't list them. An origin doesn't have to start at a key the wallet holds: if the wallet imported only an account xprv with its master's origin (e.g. [fp/48h/1h/0h/2h]tprv...), a key whose origin starts with that one is matched by deriving the rest of the path from the account key.

Commits

Commit Author
1‑3 #35918 pseudoramdom
4‑7 key/policy inspection, getdescriptorinfo verbose w0xlt (see changes below)
8 script: add AnalyzeDescriptor() for multisig setups co-authored with w0xlt
9 rpc: move descriptor key JSON helpers to a shared file move-only
10 rpc: add multisig analysis to getdescriptorinfo verbose
11 wallet: add analyzeDescriptor to the wallet interface co-authored with w0xlt
12 wallet, rpc: add analyzedescriptor co-authored with w0xlt
13 doc: add release note for #36885

Changes made to the inspection commits (4-7)

The inspection commits come from w0xlt's descriptor inspection branch. These changes were made on top, for w0xlt to review and agree with or not (this section will be removed once agreed):

  • script: expose key expression structure (was "expose structured key program data")
    • Use m_root_extkey instead of *GetRootExtPubKey().
    • The derivation test also covers /0h/* and /1/*h, checking the last-hardened and derived caches.
    • wide += ')' instead of ")" in the participant test (clang-tidy performance-prefer-single-char-overloads).
  • script: identify descriptor key occurrences
    • KeyRole() is pure virtual; descriptors without key arguments (addr, raw, sh, wsh) say so explicitly with NONFATAL_UNREACHABLE().
    • Comment noting that frame is invalidated by the following push_back.
    • The walletload test mock is reduced to return {}.
  • script: expose descriptor policy nodes
    • The header documents the two forms of the same construct (descriptor function vs Miniscript fragment).
    • Assert → CHECK_NONFATAL; explicit static_cast<uint32_t> for the threshold; /*value=*/0 named on the addr()/raw() nodes.
    • The fuzz target checks where each child role may appear (tap leaves only under tr, script only under sh/wsh, the Taproot internal key only on tr, the output key only on rawtr).
  • rpc: add verbose option to getdescriptorinfo
    • The multipath note moved to the verbose argument help; the policy help explains both forms.
    • Tests for an origin without a path and for MuSig participant origins.

Open question: script/descriptor_analysis.h describes and gives no verdict, while script/descriptor_analyzer.h gives the verdict; the names are easy to mix up. Rename the first to script/descriptor_inspection.h?

Design choices

  • An unrecognized descriptor claims no setup: no threshold, cosigners, sorting or key path. For example wsh(sortedmulti(2,A,A,C)) is not a 2-of-3, since A alone can spend. Each issue lists the key IDs involved instead.
  • The same xpub with different paths in two cosigner slots is a repeated_key (so is the same public key with another chain code, ignoring parity), as is an xpub and its own unhardened child xpub (checked by deriving it, whatever the child's chain code or parity), and so are slots linked through a chain of these. BIP 388 allows the same key with disjoint paths in general policies, but in a k-of-n it lets one holder fill two slots.
  • A Taproot key path is either nums or musig. Any other internal key, or a musig() of fewer than k distinct cosigners or with an outsider, is key_path_spendable: it lets someone spend without k cosigners. A musig() participant with a hardened derivation step (the other cosigners couldn't derive the key) is reported as hardened_derivation on that participant, and a repeated participant (same root key, or same derived key) as repeated_key.
  • A cosigner, musig() participant or Taproot internal key that can't derive addresses at all (e.g. an xpub claiming the maximum BIP32 depth, or a musig() followed by more than 255 derivation steps) is not_derivable.
  • A cosigner that is the NUMS point, as a key or as an xpub, is unspendable_key: no one can sign for it, so a 2-of-2 with it could never be spent.
  • For a multipath descriptor every path is analyzed and must be the same setup (branches_differ otherwise), and the issues of every path are returned. keys and policy describe the first path, and first_addresses lists index 0 of every path, so participants comparing them also catch a different change path. This is a quick check only: descriptors with the same first addresses and analysis can still differ later (e.g. multi() and sortedmulti() of the same keys), so to confirm a shared setup, participants compare the descriptors themselves. For combo(), that is its first address in deriveaddresses (P2PKH).
  • hasprivatekeys (as in getdescriptorinfo) tells whether the descriptor contains private keys: whoever holds it can sign for those keys, so a descriptor received from a coordinator shouldn't have any. It isn't an issue, since importing one's own xprv this way is normal, so recognized doesn't look at private keys. Those keys never make a key mine.
  • can_sign means the wallet holds the private key for at least one key of the descriptor, whatever its shape. Whether it is a recognized k-of-n is a separate answer, analysis.recognized.

The functional test scenarios of #36325 were adapted here. The analysis differs from that wizard in a few places:

  • wsh(multi(...)) is recognized, with sorted: false: it is a valid k-of-n, and requiring sortedmulti was the wizard's own policy.
  • A musig() key path of at least k distinct cosigners is recognized: those cosigners can already spend through the leaf.
  • A single-path descriptor (/0/*) is recognized; multipath_expansion already shows whether it is multipath.

Known limits

  • A child xpub is found through its parent fingerprint and child number, which whoever writes the descriptor controls. One that is hardened, more than one level down, or whose metadata was changed can't be linked to its parent without the private key, so it is not reported as a repeated_key. Likewise, only the NUMS point itself is an unspendable_key: any other key no one can sign for (e.g. a child of it) looks like a normal key. No check can show that different keys belong to different people: each cosigner should confirm with analyzedescriptor that their own key is mine.
  • An extended key is mine only if a descriptor holding it also holds its private key, as in gethdkeys. If the wallet holds the private key alone in another descriptor (e.g. imported as a WIF in pk()), the key is watch_only and can_sign is false. That matches what the wallet can do: each descriptor signs with its own keys, and none has both the private key and the chain code.
  • A plain public key without an origin is only found if the wallet has already derived it (used addresses and the keypool lookahead), the same range getaddressinfo knows about.
  • No warning is given when the wallet alone holds enough keys to meet the threshold (e.g. two accounts of one wallet as two cosigners). The per-key wallet field shows it: count the keys marked mine.
  • can_sign doesn't count keys held on an external signer, since the wallet doesn't hold their private keys: a hardware-wallet user's own cosigner key shows as watch_only or not_mine. The wallet can't tell which keys the device holds.
  • Cosigners whose origins share a master fingerprint likely come from the same seed, but this isn't reported: the fingerprint is unverified (it can be left out or edited), and one person may hold two keys on purpose. keys shows each origin.

A release note is included (doc/release-notes-36885.md).

@DrahtBot

DrahtBot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Approach ACK w0xlt

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:

  • #36710 (test: Replace hardcoded extended keys with ExtendedKey helpers by nebula-21)
  • #36648 (descriptor, rpc, wallet: do not echo key material in error messages by fametrano)
  • #36167 (build: Enable -Wunused by fanquake)
  • #36154 (wallet: fill PSBT_GLOBAL_XPUB by jeanpablojp)
  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #36070 (wallet: Add deriveHDKey interface by PraneethGunas)
  • #36005 (rpc, descriptor: warn when multipath expansion clones single-path key expressions by pythcoiner)
  • #35918 (descriptor: Expose key expression parsing by pseudoramdom)
  • #35444 (wallet: make descriptor SPKM mutex non-recursive by w0xlt)
  • #35377 (wallet: Allow importing of descriptors without private keys when the wallet has the private keys by achow101)
  • #35302 (Silent Payments: Sending (take 2) by Eunovo)
  • #34520 (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko)

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.

@w0xlt

w0xlt commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Approach ACK

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/44330374279/job/134892869102
LLM reason (✨ experimental): CI failed because the IWYU lint check modified src/script/descriptor_analyzer.cpp, leaving a diff that caused git diff --exit-code to fail.

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.

pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 25, 2026
@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task Alpine (musl): https://github.com/bitcoin/bitcoin/actions/runs/45706057177/job/139528199943
LLM reason (✨ experimental): CI failed to build test_bitcoin: -Werror=range-loop-construct rejects binding const std::string& to temporary strings in descriptor_analyzer_tests.cpp:329.

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.

pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 25, 2026
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 26, 2026
Expose an owned policy tree with typed descriptor and Miniscript
operators, local values and data, explicit child roles, and references
to the public key occurrence inventory. Preserve Taproot leaf order and
depths, and keep raw scripts and addresses explicitly opaque.

Build key occurrences and policy nodes in one iterative traversal
without serializing subtrees, so the result is linear in the
descriptor and each key argument's occurrence ID is known when its
policy node is created. The key inventory becomes the policy's key
list. Map Miniscript operands through provider-local indices so
inferred and cloned descriptors retain their correct key references.

Cover structure, thresholds, hashes, opaque forms, reference integrity,
and exact node counts. Check linear retained structure for 3,200 nested
timelocks and 1,024 Taproot leaves, and exercise parsed and inferred
policies, including MuSig participant links, in the descriptor fuzz
targets.
With verbose=true, getdescriptorinfo also returns the descriptor's key
occurrences and policy structure, built from Descriptor::GetPolicy().

Both are flat arrays whose indices are the IDs used within the result,
so deep policies do not become deeply nested JSON. Keys report their
role, public key material, derivation, and origin. Private keys in the
input are reported by their public form. Policy nodes name their
descriptor function or Miniscript fragment, and each child edge states
its role in the parent, or its depth for a Taproot leaf.

Mark the new fields as experimental, since their names form a new
interface. Test the output for wsh, Taproot with MuSig, each child
role, hashes, sorted multisig, opaque scripts, private keys, and
multipath descriptors.
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 26, 2026
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 26, 2026
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 26, 2026
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 26, 2026
pablomartin4btc added a commit to pablomartin4btc/bitcoin that referenced this pull request Nov 27, 2026
pablomartin4btc and others added 6 commits November 27, 2026 04:01
Tell whether a parsed descriptor is a recognized k-of-n multisig setup,
using only its structure (no wallet). This is the check a participant
needs before importing a descriptor received from a coordinator.

Recognized shapes are wsh((sorted)multi) and tr(K,(sorted)multi_a) with
a single leaf, where K is the BIP 341 NUMS point or a musig() of at
least k distinct cosigners. Every cosigner must be an extended key other
than the NUMS point, with an unhardened ranged derivation that can
derive addresses, every musig() participant must be derivable without
private keys, and the internal key must derive within the maximum BIP32
depth. Anything else is reported as unrecognized with the reasons, each
listing the keys involved, and no setup is claimed for it: no threshold,
cosigners, sorting or key path.

Two cosigner slots are the same holder if they share a root key, derive
the same key at the first address, or one has the key of the other's
unhardened child xpub (checked by deriving it). Keys are compared
without their chain codes or parity: whoever holds a private key holds
the key of either parity, with any chain code. Slots linked through a
chain of these are one group. Core accepts such descriptors, and fewer
signers than the threshold can spend from them. A hardened child can't
be derived from the xpub, so it is not linked to it. Likewise, musig()
participants that share a root key or derive the same key are one
participant. The groups are found with lookups rather than by comparing
every pair, as a musig() can have any number of participants, and a
child is derived only from the first of the xpubs sharing a root key, as
any number of them can share a fingerprint.

For multipath descriptors every branch is analyzed and must be the same
setup, and the issues of every branch are returned, each once. The
descriptor_parse fuzz targets check the analysis invariants.

Co-authored-by: w0xlt <[email protected]>
Move the code that turns a descriptor's key occurrences into JSON, and
the help for those fields, from rpc/output_script.cpp (node library) to
rpc/descriptor_util.cpp (common library), so a wallet RPC can return the
same fields. The multisig analysis helpers are added there next.

Move-only, apart from exposing the functions and the help fields. Review
with --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change.
Return the result of AnalyzeDescriptor() as an "analysis" object next to
"keys" and "policy", referring to the same key IDs. This gives users and
tools such as a multisig setup wizard the setup check without parsing
the descriptor string or loading a wallet.

For a multipath descriptor, "keys" and "policy" still describe the first
path, while the analysis checks every path. An unrecognized descriptor
returns only its issues.

The JSON helpers and help for the analysis go in rpc/descriptor_util.cpp,
next to the key ones, so the wallet RPC can return the same fields.
Combine AnalyzeDescriptor() with what only the wallet knows: which of
the descriptor's keys it holds, and so whether it can sign. Also return
the first address of each path (e.g. receive and change), which
participants can compare as a quick check that they built the same
wallet; only comparing the descriptors confirms it. For a path with
several scripts, like combo(), that is the first script with an address,
as deriveaddresses lists. Any descriptor is accepted; the multisig
analysis tells whether it is a recognized setup. Whether the descriptor
contains private keys is returned too: whoever holds it can sign for
those keys, so a received setup shouldn't have any.

An extended key is the wallet's if it is one of the wallet's HD keys, or
if deriving the rest of its origin path from one of them gives the same
key: from the HD key with the origin fingerprint, or after the origin
the wallet's descriptors give that HD key, e.g. an account xprv imported
with its master's origin. It is mine only if a descriptor holding it also
holds its private key, as in gethdkeys: the wallet signs with each
descriptor's own keys. A cosigner key usually has a hardened origin
path, so checking it needs the private key. A locked wallet is not an
error: such keys are reported as unknown, and the caller can ask the
user to unlock and retry, even when the wallet also holds the key
without its private key. Only the one candidate key is decrypted, and
none when the key is one of the wallet's HD keys itself, which is
checked first.

A constant key is the wallet's if the wallet stores its private key, or
if it was derived from one of the wallet's HD keys, checked the same way
from its origin: the one in the descriptor, or the one the wallet
recorded when it derived the key, as for a public key from
getaddressinfo. The new DescriptorScriptPubKeyMan::GetPubKeyOrigin()
returns that recorded origin without any private key. A key the wallet
has derived is at least watch-only.

Keys the wallet holds only as musig() participants are matched too, even
though GetHDPubKeys() (and so gethdkeys) leaves them out.

Co-authored-by: w0xlt <[email protected]>
Expose the wallet's descriptor analysis as an RPC: the same keys and
multisig analysis as getdescriptorinfo verbose, plus which keys this
wallet holds, whether it can sign, the first address of each path that
participants compare, and hasprivatekeys, as in getdescriptorinfo. Any
descriptor is accepted.

It follows the usual wallet RPC rules (-rpcwallet when several wallets
are loaded, unavailable with -disablewallet). A locked wallet is not an
error: keys that need a private key to check are reported as "unknown"
and can_sign is left out. Without a wallet, getdescriptorinfo verbose
gives the rest.

Co-authored-by: w0xlt <[email protected]>
willcl-ark added a commit to willcl-ark/nix that referenced this pull request Nov 27, 2026
Reconciliation re-checked every finding ever reported on a PR on each push,
including ones an earlier round had source-verified as fixed or invalid. On
long-lived PRs most of its Opus input went to these: 41 of 47 findings on
bitcoin/bitcoin#36885 job 3234 were already fixed, and PR 1142 re-checked the
same 27 fixed findings in consecutive runs at 6-7M input each.

Closed findings now stay in review memory unchanged, without a new history
entry, and are left out of the reconciliation input. Their per-review
candidate IDs are cleared so they cannot link to unrelated current findings.
Reconciliation is skipped when no open findings remain. A regression that
returns after a fix is raised again by discovery as a new finding.

Duplicates are still reverified, since their status follows their canonical
record.
@pablomartin4btc

Copy link
Copy Markdown
Member Author

-Updates:

  • dd636a5 → be7a2d1, rebased onto master 3e4c803 (it had the secp256k1 CMake 4.5 fix from Update secp256k1 subtree to latest master #36890, which the "Windows native, fuzz" job needed). Commits 1–5 and 7 are unchanged; the commits after 8 were reordered (see below), and a release note was added as commit 13.
  • Addressed findings from several rounds of Ralph:
    • Analysis (getdescriptorinfo verbose and analyzedescriptor)

      • musig() participants: one that needs a hardened derivation step is reported as hardened_derivation, and a repeated one (same root key, or deriving the same key) as repeated_key, on the participant IDs.
      • repeated_key now also catches:
        • an xpub next to its own unhardened direct child xpub (checked by deriving it, whatever the child's chain code or parity);
        • the same public key in two xpubs, whatever their chain codes and ignoring parity;
        • slots linked through a chain of repeated keys.

      The help says which related keys can be detected, and that each cosigner should still confirm their own key is mine. A direct child xpub is found through its parent fingerprint and child number.

      • New issue not_derivable: a cosigner, musig() participant or Taproot internal key that can't derive addresses (e.g. an xpub claiming the maximum BIP32 depth, or a musig() followed by more than 255 derivation steps).
      • New issue unspendable_key: a cosigner that is the NUMS point, as a key or as an xpub (no one can sign for it).
      • For a multipath descriptor, the issues of every path are returned, not only the first path's.
      • Repeated keys are now grouped with lookups instead of comparing every pair. A musig() can have any number of participants, and a large one took time quadratic in their count (32,000 participants: 0.95s → 0.24s for getdescriptorinfo verbose; the plain call takes 0.17s). A child xpub is also derived only from the first of the xpubs sharing a root key, since any number of them can share a fingerprint with different chain codes (500 such parents and 499 children: 4.22s → 0.12s). I can add a benchmark if reviewers want one.
    • Wallet (analyzedescriptor / interfaces::Wallet::analyzeDescriptor)

      • first_address is now first_addresses: index 0 of every path (receive and change), so a descriptor with a different change path no longer looks identical. It uses private keys given in the descriptor. For combo() it is the P2PKH address, the first one deriveaddresses lists (before, it was left out, since the first script is P2PK). The help says they are a quick check only: descriptors with the same first addresses and analysis can still differ later (e.g. multi() and sortedmulti() of the same keys), so to confirm a shared setup, compare the descriptors themselves.
      • New hasprivatekeys (as in getdescriptorinfo): a received descriptor with a cosigner's xprv lets anyone holding it sign for that key. It isn't reported as an issue, since importing one's own xprv this way is normal, and the recognized help says private keys aren't looked at. Those keys never make a key mine (tested).
      • A plain public key the wallet derived (e.g. from getnewaddress/getaddressinfo) is matched through its origin: either the one in the descriptor or the one the wallet recorded (new DescriptorScriptPubKeyMan::GetPubKeyOrigin(), no private key needed). If the wallet has it without its private key, it is watch_only.
      • Keys the wallet holds only as musig() participants are matched.
      • A key below an account xprv the wallet imported with its master's origin is matched by deriving the rest of its origin path from the account key. Before, the wallet's own receive keys were watch_only in that case, and xpubs below the account were not_mine. This was listed as a known limit, which is now removed.
      • Taproot constant keys match with either parity (02/03/x-only).
      • A key that is one of the wallet's HD keys is matched first, so no private key is decrypted for it. Before, a master holding the same account could be decrypted to derive it.
      • "unknown" only appears when the wallet is locked, and a locked wallet keeps it even when it also has the key without its private key. An HD key without its private key gives not_mine and can_sign: false.
      • The can_sign help and CanSign() doc say "recognized k-of-n" instead of "safe k-of-n". They also say that keys held on an external signer don't count, since the wallet doesn't hold their private keys (added to the known limits).
      • Clarified the key_path_spendable help. The analyzedescriptor help says, like getdescriptorinfo, that keys describes the first path and that the format is experimental.
    • Not changed (added to the known limits)

      • No warning when the wallet alone meets the threshold; the per-key wallet field shows it. There is also no warning for cosigners sharing an origin fingerprint: the fingerprint is unverified, and sharing one can be intended.
      • An xpub whose private key the wallet holds only in another descriptor (e.g. a WIF imported alone in pk()) is watch_only with can_sign: false. This is the same rule as has_private in gethdkeys, and it is what the wallet can actually do, since each descriptor signs with its own keys. A functional test checks it with walletprocesspsbt.
      • The arguments of analyzedescriptor stay in the Qt console history, as they do for getdescriptorinfo and deriveaddresses, it should go into historyFilter as they can contain BIP32 extended private keys (xprv) or WIF private keys. Thinking to add them here in a separate commit.
    • Also

      • Fixed a crash: an xpub next to its own hardened child xpub made the direct-child check call public derivation with a hardened index, which asserts. Hardened children are now skipped, since they can't be derived from the xpub. Unit and functional tests added.
      • The descriptor_parse fuzz targets now run the analysis and check its invariants (including that no issue is reported twice).
      • Reordered the commits so the key JSON helpers move to rpc/descriptor_util.cpp first (move-only, commit 9). The analysis helpers are then added there directly, instead of being added to rpc/output_script.cpp and moved later. The final code is the same.
      • Fixed CI failures on GCC and IWYU from an intermediate push.
      • After wallet: rpc: Deprecate encryptwallet RPC for encrypting existing wallets. #36387, encryptwallet needs -deprecatedrpc, so the locked-wallet test now creates its wallet with a passphrase.
      • Used named arguments for integer literals, and assert_not_equal, where the LLM linter suggested them.
      • Covered the corecheck gaps with new tests: matching through an unhardened origin path on a locked wallet, a locked wallet with both a mine and an unknown key (can_sign true), and first_addresses left out when only a later path can't be derived. Other new tests: an xpub with a different depth, parent fingerprint and child number is still the wallet's key, but one with a different chain code isn't; a key repeated only on the change path is found; the unsorted multi_a case is recognized.
      • Added the release note (commit 13) and updated the PR description accordingly (general, design choices, known limits, example output).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants