mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
Make GetInputUTXO safer: verify non-witness UTXO match
This commit is contained in:
parent
fd3f6890f3
commit
49487bc3b6
1 changed files with 4 additions and 1 deletions
|
@ -59,12 +59,15 @@ bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput
|
||||||
|
|
||||||
bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) const
|
bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) const
|
||||||
{
|
{
|
||||||
PSBTInput input = inputs[input_index];
|
const PSBTInput& input = inputs[input_index];
|
||||||
uint32_t prevout_index = tx->vin[input_index].prevout.n;
|
uint32_t prevout_index = tx->vin[input_index].prevout.n;
|
||||||
if (input.non_witness_utxo) {
|
if (input.non_witness_utxo) {
|
||||||
if (prevout_index >= input.non_witness_utxo->vout.size()) {
|
if (prevout_index >= input.non_witness_utxo->vout.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (input.non_witness_utxo->GetHash() != tx->vin[input_index].prevout.hash) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
utxo = input.non_witness_utxo->vout[prevout_index];
|
utxo = input.non_witness_utxo->vout[prevout_index];
|
||||||
} else if (!input.witness_utxo.IsNull()) {
|
} else if (!input.witness_utxo.IsNull()) {
|
||||||
utxo = input.witness_utxo;
|
utxo = input.witness_utxo;
|
||||||
|
|
Loading…
Add table
Reference in a new issue