MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ConsumeTxDestination

Function ConsumeTxDestination

src/test/fuzz/util.cpp:184–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
185{
186 CTxDestination tx_destination;
187 const size_t call_size{CallOneOf(
188 fuzzed_data_provider,
189 [&] {
190 tx_destination = CNoDestination{};
191 },
192 [&] {
193 bool compressed = fuzzed_data_provider.ConsumeBool();
194 CPubKey pk{ConstructPubKeyBytes(
195 fuzzed_data_provider,
196 ConsumeFixedLengthByteVector(fuzzed_data_provider, (compressed ? CPubKey::COMPRESSED_SIZE : CPubKey::SIZE)),
197 compressed
198 )};
199 tx_destination = PubKeyDestination{pk};
200 },
201 [&] {
202 tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
203 },
204 [&] {
205 tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
206 },
207 [&] {
208 tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
209 },
210 [&] {
211 tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
212 },
213 [&] {
214 tx_destination = WitnessV1Taproot{XOnlyPubKey{ConsumeUInt256(fuzzed_data_provider)}};
215 },
216 [&] {
217 tx_destination = PayToAnchor{};
218 },
219 [&] {
220 std::vector<unsigned char> program{ConsumeRandomLengthByteVector(fuzzed_data_provider, /*max_length=*/40)};
221 if (program.size() < 2) {
222 program = {0, 0};
223 }
224 tx_destination = WitnessUnknown{fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(2, 16), program};
225 })};
226 Assert(call_size == std::variant_size_v<CTxDestination>);
227 return tx_destination;
228}
229
230CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<bool> compressed) noexcept
231{

Callers 3

spend.cppFile · 0.85
script.cppFile · 0.85
ConsumeScalarRPCArgumentFunction · 0.85

Calls 8

CallOneOfFunction · 0.85
ConstructPubKeyBytesFunction · 0.85
ConsumeUInt160Function · 0.85
ConsumeUInt256Function · 0.85
ConsumeBoolMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected