|
| 1 | +// Copyright (c) 2019 The Bitcoin Core developers |
| 2 | +// Distributed under the MIT software license, see the accompanying |
| 3 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 4 | + |
| 5 | +#include <chainparams.h> |
| 6 | +#include <compressor.h> |
| 7 | +#include <core_io.h> |
| 8 | +#include <core_memusage.h> |
| 9 | +#include <policy/policy.h> |
| 10 | +#include <pubkey.h> |
| 11 | +#include <script/descriptor.h> |
| 12 | +#include <script/script.h> |
| 13 | +#include <script/sign.h> |
| 14 | +#include <script/signingprovider.h> |
| 15 | +#include <script/standard.h> |
| 16 | +#include <streams.h> |
| 17 | +#include <test/fuzz/fuzz.h> |
| 18 | +#include <util/memory.h> |
| 19 | + |
| 20 | +void initialize() |
| 21 | +{ |
| 22 | + // Fuzzers using pubkey must hold an ECCVerifyHandle. |
| 23 | + static const auto verify_handle = MakeUnique<ECCVerifyHandle>(); |
| 24 | +} |
| 25 | + |
| 26 | +void test_one_input(const std::vector<uint8_t>& buffer) |
| 27 | +{ |
| 28 | + const CScript script(buffer.begin(), buffer.end()); |
| 29 | + |
| 30 | + std::vector<unsigned char> compressed; |
| 31 | + (void)CompressScript(script, compressed); |
| 32 | + |
| 33 | + CTxDestination address; |
| 34 | + (void)ExtractDestination(script, address); |
| 35 | + |
| 36 | + txnouttype type_ret; |
| 37 | + std::vector<CTxDestination> addresses; |
| 38 | + int required_ret; |
| 39 | + (void)ExtractDestinations(script, type_ret, addresses, required_ret); |
| 40 | + |
| 41 | + (void)GetScriptForWitness(script); |
| 42 | + |
| 43 | + const FlatSigningProvider signing_provider; |
| 44 | + (void)InferDescriptor(script, signing_provider); |
| 45 | + |
| 46 | + (void)IsSegWitOutput(signing_provider, script); |
| 47 | + |
| 48 | + (void)IsSolvable(signing_provider, script); |
| 49 | + |
| 50 | + txnouttype which_type; |
| 51 | + (void)IsStandard(script, which_type); |
| 52 | + |
| 53 | + (void)RecursiveDynamicUsage(script); |
| 54 | + |
| 55 | + std::vector<std::vector<unsigned char>> solutions; |
| 56 | + (void)Solver(script, solutions); |
| 57 | + |
| 58 | + (void)script.HasValidOps(); |
| 59 | + (void)script.IsPayToScriptHash(); |
| 60 | + (void)script.IsPayToWitnessScriptHash(); |
| 61 | + (void)script.IsPushOnly(); |
| 62 | + (void)script.IsUnspendable(); |
| 63 | + (void)script.GetSigOpCount(/* fAccurate= */ false); |
| 64 | +} |
0 commit comments