| 182 | } |
| 183 | |
| 184 | CTxDestination 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 | |
| 230 | CKey ConsumePrivateKey(FuzzedDataProvider& fuzzed_data_provider, std::optional<bool> compressed) noexcept |
| 231 | { |
no test coverage detected