Review report

core: PR #35918

3 suggestions

Optional improvements

Link

[suggestion] · ParsePubkey applies taproot rules to keys intended for P2WSH

A P2WSH setup flow cannot use this API to reject x-only keys and musig() at paste time, and providers do not expose whether a key is x-only.

Location: src/script/descriptor.cpp:2920 (head).

Details and suggested fix

This overload always parses with ParseScriptContext::P2TR, which accepts 32-byte x-only hex keys and musig() and converts WIF keys to x-only providers. wsh(sortedmulti()) uses the P2WSH context, which rejects the first two forms. A flow that builds P2WSH descriptors must therefore filter those inputs itself. The provider interface does not expose x-only status: the key is stored as 02||x, GetSize() returns 33, GetRootPubKey() returns that even-Y key, and m_xonly is private. Only the length of ToString() reveals the x-only form. Passing its string on to descriptor assembly causes a later “Pubkey ... is invalid” error; using GetRootPubKey() directly instead yields the even-Y key, which differs from the cosigner’s key when that key has odd Y. Let callers select segwit v0 or taproot rules, mapped to P2WSH or P2TR, so parsing matches the descriptor being built. No in-tree caller of this overload exists, so the effect on the wizard is unconfirmed.


Link

[suggestion] · HavePrivateKeys() misses partially private musig() expressions

A caller using HavePrivateKeys() to reject private material would accept musig(xprv…,xpub…), even though the xprv is stored in out.

Location: src/script/descriptor.h:171 (head).

Details and suggested fix

MuSigPubkeyProvider::HavePrivateKeys() returns true only when every participant has private data, while ToPrivateString() returns true when any participant does. For musig(xprv…,xpub…), parsing adds the xprv to out, but HavePrivateKeys(out) on the returned provider is false. The header comment does not explain this distinction, and the PR identifies rejecting private keys as a caller policy. Clarify in the ParsePubkey() comment that callers should check !out.keys.empty() to detect any private key material, and add a musig(xprv…,xpub…) case to parse_pubkey_musig to pin down the behavior. No caller of the new overload exists yet.


Link

[suggestion] · Parsed musig() providers do not expose participant origins

GetOriginInfo() returns nullopt for musig(), so callers cannot inspect participant origins without re-parsing the expression.

Location: src/script/descriptor.h:151 (head).

Details and suggested fix

ParsePubkey() accepts musig(...), but MuSigPubkeyProvider keeps its participant providers private and does not override GetOriginInfo(), so it inherits the nullopt default. Its GetRootPubKey() and GetRootExtPubKey() also return nullopt. For an expression such as musig([deadbeef/48h/0h/0h/2h]xpub…,xpub…), callers cannot read participant fingerprints or paths from the returned provider and must re-parse the string. If the setup flow needs participant origins, expose the participant providers or their origin information. Otherwise, document that GetOriginInfo() covers only single-key providers. No caller in this checkout parses musig() through this API, so whether the GUI needs this is unconfirmed.


Coverage details