MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET_INIT

Function FUZZ_TARGET_INIT

src/test/fuzz/psbt.cpp:30–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30FUZZ_TARGET_INIT(psbt, initialize_psbt)
31{
32 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
33 PartiallySignedTransaction psbt_mut;
34 // ELEMENTS: needed as Solver depends on Params()
35 SelectParams(CBaseChainParams::LIQUID1);
36 std::string error;
37 if (!DecodeRawPSBT(psbt_mut, fuzzed_data_provider.ConsumeRandomLengthString(), error)) {
38 return;
39 }
40 const PartiallySignedTransaction psbt = psbt_mut;
41
42 const PSBTAnalysis analysis = AnalyzePSBT(psbt);
43 (void)PSBTRoleName(analysis.next);
44 for (const PSBTInputAnalysis& input_analysis : analysis.inputs) {
45 (void)PSBTRoleName(input_analysis.next);
46 }
47
48 (void)psbt.IsNull();
49
50 const CMutableTransaction& mtx = psbt.GetUnsignedTx();
51 const PartiallySignedTransaction psbt_from_tx{mtx};
52
53 for (const PSBTInput& input : psbt.inputs) {
54 (void)PSBTInputSigned(input);
55 (void)input.IsNull();
56 }
57 (void)CountPSBTUnsignedInputs(psbt);
58
59 for (const PSBTOutput& output : psbt.outputs) {
60 (void)output.IsNull();
61 }
62
63 for (const auto& input : psbt.inputs) {
64 CTxOut tx_out;
65 if (input.GetUTXO(tx_out)) {
66 (void)tx_out.IsNull();
67 (void)tx_out.ToString();
68 }
69 }
70
71 psbt_mut = psbt;
72 (void)FinalizePSBT(psbt_mut);
73
74 psbt_mut = psbt;
75 CMutableTransaction result;
76 if (FinalizeAndExtractPSBT(psbt_mut, result)) {
77 const PartiallySignedTransaction psbt_from_tx{result};
78 }
79
80 PartiallySignedTransaction psbt_merge;
81 if (!DecodeRawPSBT(psbt_merge, fuzzed_data_provider.ConsumeRandomLengthString(), error)) {
82 psbt_merge = psbt;
83 }
84 psbt_mut = psbt;
85 (void)psbt_mut.Merge(psbt_merge);
86 psbt_mut = psbt;
87 (void)CombinePSBTs(psbt_mut, {psbt_mut, psbt_merge});

Callers

nothing calls this directly

Calls 15

SelectParamsFunction · 0.85
DecodeRawPSBTFunction · 0.85
AnalyzePSBTFunction · 0.85
PSBTRoleNameFunction · 0.85
PSBTInputSignedFunction · 0.85
CountPSBTUnsignedInputsFunction · 0.85
FinalizePSBTFunction · 0.85
FinalizeAndExtractPSBTFunction · 0.85
CombinePSBTsFunction · 0.85
GetUnsignedTxMethod · 0.80
GetUTXOMethod · 0.80

Tested by

no test coverage detected