2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
+ #include < pubkey.h>
5
6
#include < test/fuzz/util.h>
6
7
#include < test/util/script.h>
7
8
#include < util/rbf.h>
@@ -308,7 +309,7 @@ uint32_t ConsumeSequence(FuzzedDataProvider& fuzzed_data_provider) noexcept
308
309
CTxDestination ConsumeTxDestination (FuzzedDataProvider& fuzzed_data_provider) noexcept
309
310
{
310
311
CTxDestination tx_destination;
311
- CallOneOf (
312
+ const size_t call_size{ CallOneOf (
312
313
fuzzed_data_provider,
313
314
[&] {
314
315
tx_destination = CNoDestination{};
@@ -325,13 +326,20 @@ CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) no
325
326
[&] {
326
327
tx_destination = WitnessV0KeyHash{ConsumeUInt160 (fuzzed_data_provider)};
327
328
},
329
+ [&] {
330
+ tx_destination = WitnessV1Taproot{XOnlyPubKey{ConsumeUInt256 (fuzzed_data_provider)}};
331
+ },
328
332
[&] {
329
333
WitnessUnknown witness_unknown{};
330
- witness_unknown.version = fuzzed_data_provider.ConsumeIntegral <uint32_t >();
331
- const std::vector<uint8_t > witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes <uint8_t >(40 );
334
+ witness_unknown.version = fuzzed_data_provider.ConsumeIntegralInRange (2 , 16 );
335
+ std::vector<uint8_t > witness_unknown_program_1{fuzzed_data_provider.ConsumeBytes <uint8_t >(40 )};
336
+ if (witness_unknown_program_1.size () < 2 ) {
337
+ witness_unknown_program_1 = {0 , 0 };
338
+ }
332
339
witness_unknown.length = witness_unknown_program_1.size ();
333
340
std::copy (witness_unknown_program_1.begin (), witness_unknown_program_1.end (), witness_unknown.program );
334
341
tx_destination = witness_unknown;
335
- });
342
+ })};
343
+ Assert (call_size == std::variant_size_v<CTxDestination>);
336
344
return tx_destination;
337
345
}
0 commit comments