From bcd7de55a40b8f9e4e2f1993a602b868e56d06b8 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 14 Sep 2021 18:57:48 +0000 Subject: [PATCH] fuzz: update psbt fuzztest for PSBT2 changes The `psbt.tx` Optional is no longer safe to dereference just because decoding succeeded. --- src/test/fuzz/psbt.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/fuzz/psbt.cpp b/src/test/fuzz/psbt.cpp index 40e6fb1738..d408d1b140 100644 --- a/src/test/fuzz/psbt.cpp +++ b/src/test/fuzz/psbt.cpp @@ -42,11 +42,8 @@ void test_one_input(const std::vector& buffer) (void)psbt.IsNull(); - Optional tx = psbt.tx; - if (tx) { - const CMutableTransaction& mtx = *tx; - const PartiallySignedTransaction psbt_from_tx{mtx}; - } + const CMutableTransaction& mtx = psbt.GetUnsignedTx(); + const PartiallySignedTransaction psbt_from_tx{mtx}; for (const PSBTInput& input : psbt.inputs) { (void)PSBTInputSigned(input); @@ -57,9 +54,9 @@ void test_one_input(const std::vector& buffer) (void)output.IsNull(); } - for (size_t i = 0; i < psbt.tx->vin.size(); ++i) { + for (const auto& input : psbt.inputs) { CTxOut tx_out; - if (psbt.inputs.at(i).GetUTXO(tx_out)) { + if (input.GetUTXO(tx_out)) { (void)tx_out.IsNull(); (void)tx_out.ToString(); }