Review report

core: PR #36343

2 suggestions

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

Optional improvements

Link

[suggestion] · analyzepsbt reports a finalizer role for inputs that cannot be finalized

For the tested PSBT, analyzepsbt points to the finalizer even though finalizepsbt returns complete: false with the invalid witness unchanged, so following the hint makes no progress.

Location: src/psbt.cpp:814 (head).

Details and suggested fix

The new verification check is only in FinalizePSBT. When PSBTInputSignedAndVerified fails, AnalyzePSBT calls SignPSBTInput, which can still succeed: existing final fields mark the signature data complete, and ProduceSignature returns early. AnalyzePSBT therefore sets next to FINALIZER.

After this change, finalizepsbt returns the PSBT with the invalid final_scriptwitness unchanged. The wallet signer and descriptorprocesspsbt skip inputs that already have final fields, so no Core role can make progress on this input. In the Qt PSBT dialog without a wallet loaded, the status still says the transaction is fully signed and ready for broadcast, while the Broadcast button is disabled. Before this change, finalization produced a transaction that failed script verification. This is an inaccurate hint, not a safety regression.

Consider not reporting FINALIZER when existing final fields fail verification, and assert analyzepsbt's next value in the new test. An unconditional SetInvalid could misreport a valid Taproot final input when verification fails because another input's UTXO is missing. Returning an error from SignPSBTInput would also break the fee-estimation pass, which calls it without txdata and relies on the short-circuit for already-final Taproot inputs. Which role or error to report is a maintainer decision because BIP174 has no role for removing invalid final fields.


Link

[suggestion] · The new comment misstates how SignPSBTInput handles final fields

The comment says SignPSBTInput does not check existing final fields, but it runs the same verification check and ignores its failure.

Location: src/psbt.cpp:812 (head).

Details and suggested fix

SignPSBTInput calls PSBTInputSignedAndVerified with the same txdata and returns early if it succeeds. If the check fails, execution continues: FillSignatureData marks existing final fields complete, and ProduceSignature returns true immediately. The new check therefore repeats verification because SignPSBTInput can succeed despite a failed check. The comment also obscures the same short-circuit in AnalyzePSBT. Replace it with: “SignPSBTInput can succeed for an input whose existing final fields fail verification, because FillSignatureData marks them complete and ProduceSignature returns early, so re-verify the final scripts here.” The commit message makes the same inaccurate claim that existing final fields are never verified.


Coverage details

Earlier concerns

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