aboutsummaryrefslogtreecommitdiff
path: root/src/psbt.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2021-06-07 16:47:33 -0700
committerPieter Wuille <pieter@wuille.net>2021-06-12 12:25:28 -0700
commit49487bc3b6038393c1b9c2dbdc04a78ae1178f1a (patch)
tree00c243e51ff179a657242a7f718af6c9527542ce /src/psbt.cpp
parentfd3f6890f3dfd683f6f13db912caf5c4288adf08 (diff)
downloadbitcoin-49487bc3b6038393c1b9c2dbdc04a78ae1178f1a.tar.xz
Make GetInputUTXO safer: verify non-witness UTXO match
Diffstat (limited to 'src/psbt.cpp')
-rw-r--r--src/psbt.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp
index 9894749fab..5445bc8aa1 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -59,12 +59,15 @@ bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput
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;
if (input.non_witness_utxo) {
if (prevout_index >= input.non_witness_utxo->vout.size()) {
return false;
}
+ if (input.non_witness_utxo->GetHash() != tx->vin[input_index].prevout.hash) {
+ return false;
+ }
utxo = input.non_witness_utxo->vout[prevout_index];
} else if (!input.witness_utxo.IsNull()) {
utxo = input.witness_utxo;