| 27 | } |
| 28 | |
| 29 | FUZZ_TARGET_INIT(transaction, initialize_transaction) |
| 30 | { |
| 31 | CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); |
| 32 | try { |
| 33 | int nVersion; |
| 34 | ds >> nVersion; |
| 35 | ds.SetVersion(nVersion); |
| 36 | } catch (const std::ios_base::failure&) { |
| 37 | return; |
| 38 | } |
| 39 | bool valid_tx = true; |
| 40 | const CTransaction tx = [&] { |
| 41 | try { |
| 42 | CMutableTransaction mtx{deserialize, ds}; |
| 43 | mtx.witness.vtxinwit.resize(mtx.vin.size()); |
| 44 | return CTransaction(mtx); |
| 45 | } catch (const std::ios_base::failure&) { |
| 46 | valid_tx = false; |
| 47 | return CTransaction{CMutableTransaction{}}; |
| 48 | } |
| 49 | }(); |
| 50 | bool valid_mutable_tx = true; |
| 51 | CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION); |
| 52 | CMutableTransaction mutable_tx; |
| 53 | try { |
| 54 | int nVersion; |
| 55 | ds_mtx >> nVersion; |
| 56 | ds_mtx.SetVersion(nVersion); |
| 57 | ds_mtx >> mutable_tx; |
| 58 | } catch (const std::ios_base::failure&) { |
| 59 | valid_mutable_tx = false; |
| 60 | } |
| 61 | assert(valid_tx == valid_mutable_tx); |
| 62 | if (!valid_tx) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | { |
| 67 | TxValidationState state_with_dupe_check; |
| 68 | const bool res{CheckTransaction(tx, state_with_dupe_check)}; |
| 69 | Assert(res == state_with_dupe_check.IsValid()); |
| 70 | } |
| 71 | |
| 72 | const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE}; |
| 73 | std::string reason; |
| 74 | const bool is_standard_with_permit_bare_multisig = IsStandardTx(tx, /* permit_bare_multisig= */ true, dust_relay_fee, reason); |
| 75 | const bool is_standard_without_permit_bare_multisig = IsStandardTx(tx, /* permit_bare_multisig= */ false, dust_relay_fee, reason); |
| 76 | if (is_standard_without_permit_bare_multisig) { |
| 77 | assert(is_standard_with_permit_bare_multisig); |
| 78 | } |
| 79 | |
| 80 | (void)tx.GetHash(); |
| 81 | (void)tx.GetTotalSize(); |
| 82 | try { |
| 83 | (void)tx.GetValueOutMap(); |
| 84 | } catch (const std::runtime_error&) { |
| 85 | } |
| 86 | (void)tx.GetWitnessHash(); |
nothing calls this directly
no test coverage detected