Merge ElementsProject/elements#1043: fuzz: update psbt fuzztest for PSBT2 changes

bcd7de55a4 fuzz: update psbt fuzztest for PSBT2 changes (Andrew Poelstra)

Pull request description:

  The `psbt.tx` Optional is no longer safe to dereference just because decoding succeeded.

ACKs for top commit:
  achow101:
    ACK bcd7de55a4

Tree-SHA512: 701ace683a2615a944903ec69a20d1808da03009bec6e7af76954476d4e66b122fe01657285252b90fad92cc8aadd46095c80a1ccf454ae11f0e86a550ce1a0b
This commit is contained in:
Andrew Poelstra 2021-09-14 23:43:19 +00:00
commit 787ee1e91f
No known key found for this signature in database
GPG key ID: C588D63CE41B97C1

View file

@ -42,11 +42,8 @@ void test_one_input(const std::vector<uint8_t>& buffer)
(void)psbt.IsNull();
Optional<CMutableTransaction> 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<uint8_t>& 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();
}