Review report

bitcoin/bitcoin: PR #31252

1 minor finding

Earlier concerns neither republished nor resolved: 1 minor finding · 2 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Empty redeem and witness scripts disappear from decoded RPC fields

For confirmed P2SH or P2WSH spends of an empty script with undo data available, the new decoded-script field is omitted because serialization confuses empty contents with failed extraction.

Location: src/core_io.cpp:483 (head).

Details and suggested fix

GetRedeemAndWitnessScripts represents both failed extraction and a successfully extracted zero-length script with an empty CScript. The empty() guards here therefore suppress valid results. For an output committing to HASH160(""), scriptSig OP_1 OP_0 spends the empty redeem script and leaves a truthy item. For P2WSH committing to SHA256(""), witness ["01", ""] similarly passes the hash check and leaves one truthy item after executing the empty witness script. Once confirmed with undo data available, these spends omit redeemScript or witnessScript from getrawtransaction verbosity 2, getblock verbosity 2/3, and detailed /rest/block/ JSON responses. The raw scriptSig and witness remain available; only the new informational fields are affected. Track extraction presence separately, for example with std::optional<CScript>, emit the object whenever extraction succeeds, and add confirmed empty-script regression cases. No current mainnet spend of an empty redeem or witness script was identified, so production occurrence is unconfirmed.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.