5 minor findings · 7 suggestions
Findings
[minor] · NUMS-rooted xpubs pass the cosigner checks
A NUMS-rooted ranged xpub can be accepted as a cosigner even in an unspendable 2-of-2; no current honest producer of this input was identified.
Location: src/script/descriptor_analyzer.cpp:86 (head).
Details and suggested fix
Using the existing NUMS_XPUB fixture, wsh(sortedmulti(2,A/0/*,NUMS_XPUB/0/*)) passes the type, wildcard, public-derivation and repeated-key checks, so it receives recognized: true with no issues. Public derivation produces keys for the NUMS slot, but no known signing secret, leaving this output without a feasible spending path. ClassifyKeyPath() already recognizes unhardened derivations from the same root as unspendable. Reuse that classification in CheckCosignerKeys() to report the affected cosigner ID and withhold recognition, with regression cases for both WSH cosigners and Taproot leaf cosigners.
[minor] · Over-depth internal keys still receive a recognized verdict
An over-depth NUMS or MuSig internal-key expression can receive recognized: true even though descriptor expansion fails; no current honest producer of such descriptors was identified.
Location: src/script/descriptor_analyzer.cpp:221 (head).
Details and suggested fix
ClassifyKeyPath() accepts a NUMS-rooted xpub without deriving it and classifies a MuSig aggregate without checking its aggregate derivation suffix. Consequently, a depth-255 NUMS xpub followed by /* passes recognition but cannot expand. A MuSig aggregate has the same problem with 255 fixed derivation steps followed by /*: its synthetic xpub starts at depth zero, and the wildcard requires a forbidden 256th derivation. The wallet then omits first_addresses without revising the positive verdict; import rejects the expansion failure. Derive the complete internal-key expression at index zero, including its suffix and wildcard, and report not_derivable against the internal-key ID on failure. Add boundary tests for both constructions.
[minor] · Duplicate detection scales quadratically with descriptor size
Submitting a large descriptor for analysis can force billions of pairwise duplicate checks, with repeated BIP32 derivations and multipath branches amplifying the work.
Location: src/script/descriptor_analyzer.cpp:126 (head).
Details and suggested fix
LinkedGroups() evaluates every pair before the final recognition decision. The musig() parser has no participant-count cap, so roughly 100,000 compressed-key participants, about 6.7 MB, cause about five billion predicate calls even when the descriptor is ultimately unrecognized. The bounded leaf-cosigner check is expensive too: 500 copies of one xpub and 499 other xpubs claiming it as their parent cause roughly 250,000 EC derivations per branch. Unrecognized multipath branches compare equal after their setup fields are cleared, so the full scan repeats for each branch. This work runs synchronously when a user submits the text to getdescriptorinfo with verbose=true, analyzedescriptor, or the wallet interface. These are source-derived operation counts; elapsed time has not been measured.
Build the same transitive groups through maps keyed by root and first-derived keys. Cache fingerprints and derivations for distinct parent-key/child-number pairs instead of recomputing them for every occurrence pair.
[minor] · HD-key ownership misses private keys in other managers
When an HD root's scalar is stored in another descriptor manager, analyzedescriptor can report watch_only and can_sign=false; no current normal workflow producing this split was identified.
Location: src/wallet/descriptor_analyzer.cpp:57 (head).
Details and suggested fix
Import wsh(multi(1,WIF_B,XPUB_A/0/*)), then separately import wpkh(WIF_A), where WIF_A contains XPUB_A's private scalar. The first import is permitted as a partial-private descriptor. GetHDPubKeys() associates XPUB_A only with its multisig manager, so HasPrivKey(spkms, hd_key.pubkey.GetID()) misses the scalar in the constant-key manager. An analysis containing only XPUB_A consequently reports watch_only and can_sign=false; a hardened-origin descendant is skipped before GetExtKey() can reconstruct the xprv. Check private-key presence across all descriptor managers without decrypting, as MatchConstKey() already does, and cover exact-root and hardened-origin matches with split public/private storage.
[minor] · combo() loses its derivable first address
analyzedescriptor omits first_addresses for combo() because its first expanded script is P2PK, even though later outputs have addresses.
Location: src/wallet/descriptor_analyzer.cpp:154 (head).
Details and suggested fix
ComboDescriptor::MakeScripts() emits P2PK before P2PKH and, for compressed keys, the segwit outputs. FirstAddress() calls ExtractDestination() only on scripts.front(), so the expected false result for P2PK clears first_addresses. This contradicts the help's explanation that the field is absent when addresses cannot be derived. Follow DeriveAddresses() by skipping the addressless P2PK output and selecting the first address-bearing script. Add a combo() case comparing each returned first address with the first address from deriveaddresses for that path.
Optional improvements
[suggestion] · Later multipath branches lose their issue details
The multipath verdict remains unrecognized, but later branches' failure reasons are discarded or replaced by key-less branches_differ, making diagnostics depend on branch order.
Location: src/script/descriptor_analyzer.cpp:329 (head).
Details and suggested fix
For wsh(multi(2,A/<0;1h>/*,B/<0h;1>/*)), the first branch reports hardened derivation for B and the second reports it for A. Unrecognize() clears every setup field compared by the span overload, so those branches compare equal and only B's issue survives. If the first branch is recognized instead, the later failure produces only branches_differ, without identifying the offending key. Accumulate each branch's issues and deduplicate by (kind, keys), using the corresponding occurrence IDs across parsed branches, while retaining the unrecognized verdict and branches_differ where appropriate. Test both branch orderings so users receive all actionable causes in one response.
[suggestion] · analyzedescriptor omits the shared format's caveats
analyzedescriptor returns the shared experimental keys and analysis format without its stability warning or the explanation that keys describes only the first multipath branch.
Location: src/wallet/rpc/wallet.cpp:1095 (head).
Details and suggested fix
getdescriptorinfo explicitly marks its verbose fields experimental and explains the first-path projection. analyzedescriptor uses the same serializers but carries neither qualification in its help or release note. With /<0;1>/* input, the reported key derivations therefore show only /0/* without explaining that scope. Carry the experimental warning and first-path note into the wallet RPC documentation, distinguishing the first-branch keys projection from analysis, which checks every branch, and first_addresses, which supports address agreement across branches.
[suggestion] · Child-xpub detection has an undocumented metadata dependency
A direct unhardened child can escape detection if its metadata is rewritten and its first-derived key differs, despite the help listing direct children as detectable.
Location: src/rpc/descriptor_util.cpp:30 (head).
Details and suggested fix
IsDirectChild() tries only the relationship claimed by the child's parent-fingerprint and child-number fields. Changing those fields does not change its public key or chain code, but can make the check return false; the code comment already notes that metadata can hide a child. Qualify the direct-child example in HELP_DESCRIPTOR_ANALYSIS with this dependency. Explain that this check catches mistakes rather than deliberate concealment and does not replace confirming each cosigner key with its owner.
[suggestion] · No advisory identifies a threshold owned by this wallet
An unlocked wallet can own enough distinct cosigner slots to spend alone without an advisory, although the can_sign help points to analysis.recognized as the safety verdict.
Location: src/wallet/rpc/wallet.cpp:1102 (head).
Details and suggested fix
In a 2-of-3 setup, two hardened sibling accounts such as m/48h/1h/0h/2h and m/48h/1h/1h/2h evade the public relationship checks. An unlocked wallet holding their master can verify both origins and report both slots as mine, while recognition remains true. The per-key wallet fields and analysis.cosigners already let callers detect this, but the safety wording does not distinguish structural recognition from this wallet's ability to meet the threshold alone. Add a non-blocking wallet advisory, or at least a help note, when its MINE cosigner slots meet the threshold. Do not count WATCH_ONLY or UNKNOWN, and leave structural recognition unchanged.
[suggestion] · Shared origin fingerprints receive no setup advisory
A non-blocking shared-fingerprint warning could catch accidentally repeated seeds that the public-key relationship checks miss, without treating unauthenticated origins as proof of shared control.
Location: src/script/descriptor_analyzer.cpp:157 (head).
Details and suggested fix
The functional test recognizes account keys at m/48h/1h/0h and m/48h/1h/0h/2h from the same master, both carrying its fingerprint. Their hardened relationship cannot be verified publicly, and same_holder never examines origins, so the likely same-seed mistake receives no advisory. Add a separate warning listing cosigner IDs with a shared origin fingerprint. Origins are optional and unauthenticated, and four-byte fingerprints can collide, so this should neither produce repeated_key nor clear recognized; the existing issues field is reserved for reasons to withhold recognition.
[suggestion] · The mixed UNKNOWN and MINE case is untested
The locked-wallet tests would not catch CanSign() returning unknown immediately upon encountering UNKNOWN, even when a later key is MINE.
Location: src/wallet/test/wallet_interfaces_tests.cpp:248 (head).
Details and suggested fix
The current implementation correctly keeps searching after UNKNOWN, but the tests exercise UNKNOWN with NOT_MINE and MINE with NOT_MINE separately. The existing locked fixture already provides both ingredients: AccountKey(master) needs hardened derivation and is UNKNOWN, while the exact master xpub is MINE without unlocking. Put both in one descriptor, test both orders, and assert CanSign() == true with the wallet still locked. This protects the rule that one known private-key match takes precedence over unresolved keys.
[suggestion] · WalletHDKeys() traverses the wallet's descriptors twice
The existing inventory pass can collect identical root-to-manager associations without a separate wallet-wide GetHDPubKeys() traversal under cs_wallet.
Location: src/wallet/descriptor_analyzer.cpp:135 (head).
Details and suggested fix
WalletHDKeys() first collects non-MuSig roots through GetHDPubKeys(), then visits every manager's key inventory to add only MuSig participants. That inventory already records the same m_root_extkey for every BIP32 occurrence, including ordinary descriptor keys and participants. Start with an empty map and insert every BIP32 occurrence from the existing inventory pass, without the role filter. This preserves the keys, manager sets and deduplication while removing one traversal under the wallet lock; gethdkeys can retain its intentional omission of MuSig participants.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
The setup work explicitly distinguished counting key slots from establishing independent owners. A repeated key can let one holder satisfy multiple slots, so checking only one's own key and the advertised threshold is insufficient. The tracking discussion moved from proposing refusal to warning before confirmation: duplicate keys may be intentional, Core should sign valid descriptors, and distinct keys still cannot prove distinct controlling parties.
This explains why the pinned analyzer reports repeated keys and withholds a recognized setup without rejecting the descriptor itself. It also limits the meaning of recognition: descriptor inspection cannot authenticate the human or organizational independence of the cosigners.
Source 1 · Source 2 · Source 3 · Source 4
Earlier unspendable-internal-key work separated two objectives: participants must be able to verify that the key path is unspendable, while outsiders ideally cannot identify script-only outputs. The discussion also records deployed Ledger behavior that checks whether the public-key component of an internal xpub is the BIP341 NUMS point, independently of reconstructing its chain code.
This supplies historical context for recognizing both the fixed NUMS point and synthetic xpubs rooted at that point. Verifiable absence of an extra spending authority is the relevant setup guarantee; privacy and deterministic chain-code reconstruction are separate concerns.
Source 1 · Source 2 · Source 3
Key origins were introduced to support PSBT updating and hardware-wallet xpub imports. The earlier public-descriptor import proposal #35377 explicitly uses a matching fingerprint to select a candidate wallet key, then derives the supplied path and verifies the resulting xpub. Its motivation is avoiding manual exposure of private keys. It also explicitly leaves matching through an imported account key's origin prefix to future work.
The new ownership check follows that proposal's fingerprint-plus-derivation model rather than treating an origin annotation as proof. The pinned base documentation says origins do not affect scriptPubKeys and fingerprints can collide. The imported-account limitation is therefore a previously acknowledged scope boundary, not a guarantee that every descendant of every stored xprv will be discovered.
The derivehdkey work deliberately supports sharing an account xpub below a hardened path, distinct from the participant's default single-signature descriptors. The pinned base RPC consequently requires unlocking, while descriptor documentation explains why publishing the account xpub permits subsequent public derivation without exposing the private key needed for the hardened prefix.
This explains the split between origin verification and address generation: checking whether a shared account xpub belongs to the wallet commonly needs private derivation, whereas deriving receive/change addresses from that account xpub need not. It also explains the requirement for publicly derivable ranged cosigner expressions.
The BSMS discussion proposed displaying and comparing the first receive address to mitigate a malicious coordinator exploiting the descriptor checksum's short collision resistance. Familiarity and ease of finding the first address were additional reasons. Bitcoin Core's pinned base documentation likewise tells participants to verify that they derive the same addresses.
The returned first addresses are an agreement check distinct from recognizing a threshold policy or finding one's own key. Returning one address for every multipath branch extends that check to change and other branches: equal shape, threshold, and cosigner roots do not by themselves establish identical derivation suffixes.
Source 1 · Source 2 · Source 3
Ralph's inferences
The related-xpub checks are evidence of shared control, not a complete independence test. The pinned implementation links equal root public keys, equal first-derived keys, and derivation-verified direct unhardened children, including transitive groups. Hardened relationships cannot be verified publicly; more distant ancestry or misleading metadata can also escape these particular checks.
Recognition is therefore a bounded structural assessment, conditional on the cosigner slots actually representing the intended independent authorities. Different paths under one detected root do not create independent holders, but failure to detect a relationship does not establish independence.
Under the discrete-log assumption, publicly deriving from the NUMS point preserves the absence of a known signing secret. An unhardened derivation produces a point of the form H+tG with a computable tweak; knowing its private scalar would reveal H's scalar by subtracting t. The same reasoning applies to the public Taproot tweak.
This explains why a NUMS-rooted xpub with unhardened derivation is acceptable even though its internal keys differ between addresses. The chain code selects public tweaks; it does not supply a private scalar for H.
The at-least-k MuSig rule follows from authorization-set containment: an aggregate requiring at least k distinct members of the leaf's cosigner set grants a spending route only to a coalition already authorized by the k-of-n leaf. An outsider, repeated participant, or aggregate below k cannot be counted the same way. This is policy reasoning from the pinned implementation, not an earlier historical resolution located during research.
The earlier wizard assembled an all-cosigner MuSig key path. The current recognition rule generalizes beyond all n while preserving the intended threshold authorization, conditional on independent cosigner control. Public derivability additionally lets every participant reproduce the key path without another participant's secret.
A locked-wallet unknown is an epistemic result, not evidence that the key is absent. In the pinned base, HasPrivKey includes encrypted private-key records even while locked, but obtaining the secret requires access to the encryption key. If verifying a candidate's origin needs hardened derivation, a matching fingerprint alone cannot settle ownership.
This explains why exact or publicly derivable matches can remain mine while locked, why hardened-origin candidates can be unknown, and why unknown takes precedence over a watch-only copy of the same candidate. Decrypting only the selected candidate follows the base's per-key access mechanism rather than requiring a bulk private-key inventory.
The exposed can_sign semantics describe possession of at least one private key, not completion of the spending policy or immediate ability to sign while locked. This is consistent with the existing PSBT workflow, where individual wallets contribute signatures and a separate combine/finalize step determines completeness. The precise Boolean aggregation is new interface behavior, not a universal existing wallet ownership definition.
A wallet may contribute to a multisig without meeting its threshold, and may possess a key in an unrecognized or single-signature descriptor. Consequently can_sign and analysis.recognized answer different questions. Unknown ownership prevents a definitive false, whereas a known private-key match suffices for true.