Skip to content

Commit 49487bc

Browse files
committed
Make GetInputUTXO safer: verify non-witness UTXO match
1 parent fd3f689 commit 49487bc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/psbt.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput
5959

6060
bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) const
6161
{
62-
PSBTInput input = inputs[input_index];
62+
const PSBTInput& input = inputs[input_index];
6363
uint32_t prevout_index = tx->vin[input_index].prevout.n;
6464
if (input.non_witness_utxo) {
6565
if (prevout_index >= input.non_witness_utxo->vout.size()) {
6666
return false;
6767
}
68+
if (input.non_witness_utxo->GetHash() != tx->vin[input_index].prevout.hash) {
69+
return false;
70+
}
6871
utxo = input.non_witness_utxo->vout[prevout_index];
6972
} else if (!input.witness_utxo.IsNull()) {
7073
utxo = input.witness_utxo;

0 commit comments

Comments
 (0)