Merge bitcoin/bitcoin#34272: psbt: Fix PSBTInputSignedAndVerified bounds assert

2f5b1c5f80 psbt: Fix `PSBTInputSignedAndVerified` bounds `assert` (Lőrinc)

Pull request description:

  This PR fixes an off-by-one in a debug assertion in `PSBTInputSignedAndVerified`.
  The function indexes `psbt.inputs[input_index]`, so the assertion must not allow indexing at `psbt.inputs.size()`.

  Found during review: https://github.com/bitcoin/bitcoin/pull/31650#discussion_r2685892867

ACKs for top commit:
  optout21:
    utACK 2f5b1c5f80
  maflcko:
    lgtm ACK 2f5b1c5f80
  achow101:
    ACK 2f5b1c5f80

Tree-SHA512: cec613a9a38358d5caa243197d746baa129aebfd7fe697689f28e652f94c4683873c4676d5eb2eb909ea19de5e5f6e54ecc5f3162384a48f6f38a59273667689
This commit is contained in:
Ava Chow
2026-01-13 16:24:31 -08:00

View File

@@ -325,7 +325,7 @@ bool PSBTInputSigned(const PSBTInput& input)
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, unsigned int input_index, const PrecomputedTransactionData* txdata)
{
CTxOut utxo;
assert(psbt.inputs.size() >= input_index);
assert(input_index < psbt.inputs.size());
const PSBTInput& input = psbt.inputs[input_index];
if (input.non_witness_utxo) {