1 minor finding · 2 suggestions
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · Local verification leaves analyzepsbt's finalizer guidance inconsistent
The local check leaves analyzepsbt's pre-existing next="finalizer" guidance pointing to an operation that now returns the same incomplete PSBT, without a new loss of spendability.
Location: src/psbt.cpp:814 (head).
Details and suggested fix
With a matching non_witness_utxo and no sighash mismatch, failed verification in SignPSBTInput falls through to FillSignatureData, which marks the supplied final witness complete. ProduceSignature then returns success without repairing it, and AnalyzePSBT selects FINALIZER. Retrying finalizepsbt preserves the invalid final fields and returns complete=false. Reject already-final inputs that fail verification in SignPSBTInput when txdata != nullptr, then let FinalizePSBT use that result instead of checking again. This aligns the two callers and avoids another verification per valid input. Preserve the nullptr dummy-signing path used for size estimation, because finalized Schnorr signatures cannot be verified without precomputed transaction data. Extend the regression test to check next.
Optional improvements
[suggestion] · Full-UTXO regression precondition is not asserted
The test currently reaches the regression, but a witness_utxo-only fixture would satisfy every assertion even with the production fix reverted.
Location: test/functional/rpc_psbt.py:896 (head).
Details and suggested fix
The wallet currently supplies and retains non_witness_utxo for this P2WPKH input. Successful finalization of the unmodified PSBT does not prove that property: a valid witness_utxo-only input returns early from SignPSBTInput. After corruption, that same input already returns INCOMPLETE through the existing require_witness_sig check, without the new verification, so the negative assertions would not distinguish the bug. Add assert PSBT_IN_NON_WITNESS_UTXO in flawed_psbt.i[0].map immediately after decoding. The constant is already imported.
[suggestion] · Standard-script completeness restriction lacks a release note
finalizepsbt now withholds hex for consensus-valid final scripts that fail standard script verification, but this restriction lacks a release note; no current caller relying on that extraction behavior was identified.
Location: src/psbt.cpp:814 (head).
Details and suggested fix
For externally finalized inputs with a matching non_witness_utxo and otherwise compatible fields, the base code could return complete=true despite a policy-only script failure. The added PSBTInputSignedAndVerified check uses STANDARD_SCRIPT_VERIFY_FLAGS, so the same input now returns complete=false and no hex. This is consistent with existing wallet and descriptor processing, but goes beyond rejecting invalid signatures. Add a short doc/release-notes-<PR number>.md entry explaining that finalizepsbt verifies existing final scripts against PSBT-supplied UTXO data and also rejects consensus-valid satisfactions that fail those flags, such as a SegWit-v0 witness with an uncompressed key.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Avoid repeating script verification for successful inputs
- [suggestion]: Clarify why SignPSBTInput can succeed with invalid final fields (earlier report)
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
PSBT was designed to let different wallet implementations exchange and combine signatures, including with offline signers that cannot query the UTXO set. Supplying transaction context is therefore part of its security model, not merely a serialization convenience.
FinalizePSBT operates on an exchanged PSBT and uses its supplied previous-output information rather than consulting chain state. In the pinned code, PSBTInputSignedAndVerified obtains the spent output from non_witness_utxo or witness_utxo; when using a full previous transaction, it checks its hash and output index against the outpoint.
The historical trust in final script fields came from a role contract: a finalizer was expected to construct valid scriptSigs and witnesses. In #33014, Ava Chow explicitly explained that existing code assumed a finalized PSBT already satisfied that contract, and that complete=true was intended to imply successful finalization and extraction.
This explains the assumption embodied by PSBTInput::FillSignatureData marking supplied final fields complete and ProduceSignature returning immediately for complete signature data. At the pinned base, FinalizePSBT relied on SignPSBTInput succeeding; the head additionally verifies the resulting final scripts. The historical contract explains the shortcut without establishing that externally supplied final fields deserve trust.
Signature presence and signature validity were already distinguished in earlier PSBT work because a transaction can change after signing. #30357 specifically identified PayJoin as a setting where existing signatures could cease to be valid, and its discussion argued that completeness should be accurate before any transaction hex is returned.
The affected behavior is the meaning of complete, not simply whether final fields have been populated. This history supplies the application-level reason for checking the final scripts against the current transaction. The pinned head applies that verification to FinalizePSBT using the same helper discussed in the earlier wallet and descriptor-processing work.
Source 1 · Source 2 · Source 3
Ralph's inferences
The completeness check is best understood as a script-level readiness gate for the next workflow stage, rather than a certificate of transaction-wide validity or network acceptance. Its use of standard script flags also makes that gate stricter than consensus-only script validity.
At the pinned head, FinalizePSBT invokes PSBTInputSignedAndVerified, which uses STANDARD_SCRIPT_VERIFY_FLAGS, and finalizepsbt returns hex only when finalization and extraction succeed. This connects the historical extraction invariant to ordinary transaction submission, but does not establish why every policy flag was selected. Script verification alone does not check all mempool conditions or establish that supplied outputs remain unspent.