rpc, wallet: Support BIP322 simple message signing

bitcoin/bitcoin: PR #36809

5 suggestions

Optional improvements

Link

[suggestion] · Fully keyed BIP322 failures report missing private keys

An unlocked wallet can receive Private key not available despite holding all needed keys when its only spending path requires an incompatible timelock or a MuSig2 session that one-shot signing cannot complete.

Location: src/wallet/wallet.cpp:2093 (head).

Details and suggested fix

Every SignTransaction failure maps to PRIVATE_KEY_NOT_AVAILABLE, producing RPC error -4 even after the ownership and lock guards pass. Simple proofs' zero version, locktime and sequence prevent the timelocked satisfaction, while MuSig2 requires signing rounds that this call cannot resume. The imported-key timelock and all-local MuSig2 fixtures assert this diagnosis. Use a neutral BIP322 incomplete-proof diagnostic for this path, and document the MuSig2 restriction alongside the existing timelock explanation in help and release notes. Unlike incompatible simple-proof timelocks, this MuSig2 limitation belongs to the one-shot interface: PSBT rounds can complete a proof, and an independently satisfiable script leaf can still sign.


Link

[suggestion] · GUI messages still describe SegWit signing as unsupported in this version

The unchanged Qt dialog rejects BIP322 proofs produced by the RPC while still describing SegWit message signing as unsupported in this version.

Location: src/rpc/signmessage.cpp:49 (head).

Details and suggested fix

The sign tab accepts only PKHash, and the verify tab calls MessageVerify, which rejects native witness addresses before decoding their proofs. Both tabs then display the release-wide unsupported message, despite the new RPC support for native P2WPKH, P2WSH and P2TR. Qualify both messages as a limitation of this dialog and point users to signmessage and verifymessage. Full GUI support can remain a follow-up; this clarification preserves the existing GUI behavior.


Link

[suggestion] · Non-upgrade BIP322 failures repeat signature verification

When the combined pass fails with a non-DISCOURAGE_* error, the required-only retry repeats the same script execution and uncached signature checks without changing the result.

Location: src/common/signmessage.cpp:238 (head).

Details and suggested fix

A signer can supply a tapscript that performs many valid OP_CHECKSIGVERIFYs before ending in false. Both passes redo those checks with TransactionSignatureChecker; a near-weight-limit proof can budget roughly 80,000 checks per pass. This is a static operation bound, not a timing measurement, and the RPC caller must authenticate.

Unless upgrade_error is one of the five SCRIPT_ERR_DISCOURAGE_* errors, copy it to script_error when provided and return INVALID immediately. The upgrade flags only introduce their corresponding early failures, so other errors follow the same execution under required-only flags. Keep retries for discourage failures so later required errors still win and upgrade-only failures stay INCONCLUSIVE. Valid proofs already use one pass; this shortcut does not remove repeated checks after a late discourage error.


Link

[suggestion] · Message-proof script disclosure is undocumented

Sharing a P2WSH proof or a Taproot proof produced through script fallback reveals script data that the new signmessage help and release notes do not describe.

Location: src/wallet/rpc/signmessage.cpp:25 (head).

Details and suggested fix

When no key-path signature is available, SignTaproot can fall back to the smallest satisfiable leaf and append its script and control block; the MuSig2 fallback fixture exercises this path. A directly signable key path is preferred. P2WSH proofs instead include the complete witness script. Add a sentence to help and release notes explaining that proof recipients learn that script, or the selected Taproot leaf plus its internal key and Merkle path. Other Taproot leaf scripts and private keys are not disclosed.


Link

[suggestion] · Opaque Taproot leaves lack a fuzz classification oracle

The new script-derived fuzz branch ignores verification outcomes, so it cannot detect incorrect classification of opaque Taproot leaves even though the generator supplies matching commitments.

Location: src/test/fuzz/message.cpp:105 (head).

Details and suggested fix

For successfully constructed Taproot proofs, keep version and the first control-block byte, then capture both the verification result and ScriptError. When version != TAPROOT_LEAF_TAPSCRIPT and control[0] != ANNEX_TAG, assert INCONCLUSIVE with SCRIPT_ERR_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION. The matching commitment and bounded witness make that outcome deterministic: unknown leaves are neither executed nor scanned for OP_CODESEPARATOR. The annex guard matters because a control block starting with 0x50 is parsed as an annex instead. This would catch misclassification across generated opaque versions, while the existing unit cases pin 0xc2, without changing the seed encoding.


Coverage details