Bitcoin Core  24.99.0
P2P Digital Currency
script_format.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2022 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 <consensus/consensus.h>
7 #include <core_io.h>
8 #include <policy/policy.h>
9 #include <script/script.h>
11 #include <test/fuzz/fuzz.h>
12 #include <test/fuzz/util.h>
13 #include <univalue.h>
14 
16 {
18 }
19 
21 {
22  FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
23  const CScript script{ConsumeScript(fuzzed_data_provider)};
24  if (script.size() > MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR) {
25  return;
26  }
27 
28  (void)FormatScript(script);
29  (void)ScriptToAsmStr(script, /*fAttemptSighashDecode=*/fuzzed_data_provider.ConsumeBool());
30 
32  ScriptToUniv(script, /*out=*/o1, /*include_hex=*/fuzzed_data_provider.ConsumeBool(), /*include_address=*/fuzzed_data_provider.ConsumeBool());
33 }
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
static const std::string REGTEST
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:411
@ VOBJ
Definition: univalue.h:20
static const int WITNESS_SCALE_FACTOR
Definition: consensus.h:21
std::string FormatScript(const CScript &script)
Definition: core_write.cpp:39
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:98
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false)
Definition: core_write.cpp:150
static constexpr unsigned int MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
Definition: policy.h:27
FUZZ_TARGET_INIT(script_format, initialize_script_format)
void initialize_script_format()
CScript ConsumeScript(FuzzedDataProvider &fuzzed_data_provider, const bool maybe_p2wsh) noexcept
Definition: util.cpp:366