16#include <validation.h>
25void initialize_setup()
27 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
28 g_setup = testing_setup.get();
39 FuzzedWallet fuzzed_wallet{
42 "tprv8ZgxMBicQKsPd1QwsGgzfu2pcPYbBosZhJknqreRHgsWx32nNEhMjGQX2cgFL8n6wz9xdDYwLcs78N4nsCo32cxEX8RBtwGsEGgybLiQJfk",
45 CCoinControl coin_control;
46 if (fuzzed_data_provider.ConsumeBool()) coin_control.m_version = fuzzed_data_provider.ConsumeIntegral<
unsigned int>();
47 coin_control.m_avoid_partial_spends = fuzzed_data_provider.ConsumeBool();
48 coin_control.m_include_unsafe_inputs = fuzzed_data_provider.ConsumeBool();
49 if (fuzzed_data_provider.ConsumeBool()) coin_control.m_confirm_target = fuzzed_data_provider.ConsumeIntegralInRange<
unsigned int>(0, 999'000);
50 coin_control.destChange = fuzzed_data_provider.ConsumeBool() ? fuzzed_wallet.GetDestination(fuzzed_data_provider) :
ConsumeTxDestination(fuzzed_data_provider);
51 if (fuzzed_data_provider.ConsumeBool()) coin_control.m_change_type = fuzzed_data_provider.PickValueInArray(
OUTPUT_TYPES);
53 coin_control.m_allow_other_inputs = fuzzed_data_provider.ConsumeBool();
54 coin_control.m_locktime = fuzzed_data_provider.ConsumeIntegral<
unsigned int>();
55 coin_control.fOverrideFeeRate = fuzzed_data_provider.ConsumeBool();
65 all_values += n_value;
67 tx.
vout[0].nValue = n_value;
69 LOCK(fuzzed_wallet.wallet->cs_wallet);
71 auto ret{fuzzed_wallet.wallet->mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(
MakeTransactionRef(std::move(tx)), TxStateConfirmed{chainstate.m_chain.Tip()->GetBlockHash(), chainstate.m_chain.Height(), 0}))};
75 std::vector<CRecipient> recipients;
81 destination = fuzzed_wallet.GetDestination(fuzzed_data_provider);
92 recipients.push_back({destination,
94 fuzzed_data_provider.ConsumeBool()});
97 std::optional<unsigned int> change_pos;
98 if (fuzzed_data_provider.ConsumeBool()) change_pos = fuzzed_data_provider.ConsumeIntegral<
unsigned int>();
99 (void)
CreateTransaction(*fuzzed_wallet.wallet, recipients, change_pos, coin_control);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Serialized script, used inside transaction inputs and outputs.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
FUZZ_TARGET(coin_grinder)
static constexpr auto OUTPUT_TYPES
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
Testing setup that configures a complete environment.
std::unique_ptr< interfaces::Chain > chain
CTxDestination ConsumeTxDestination(FuzzedDataProvider &fuzzed_data_provider) noexcept
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.