17#include <validation.h>
26void initialize_setup()
32FUZZ_TARGET(wallet_create_transaction, .init = initialize_setup)
35 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
38 Chainstate& chainstate{node.chainman->ActiveChainstate()};
39 ArgsManager&
args = *node.args;
44 "tprv8ZgxMBicQKsPd1QwsGgzfu2pcPYbBosZhJknqreRHgsWx32nNEhMjGQX2cgFL8n6wz9xdDYwLcs78N4nsCo32cxEX8RBtwGsEGgybLiQJfk",
63 CMutableTransaction tx;
67 all_values += n_value;
69 tx.
vout[0].nValue = n_value;
71 LOCK(fuzzed_wallet.wallet->cs_wallet);
77 std::vector<CRecipient> recipients;
83 destination = fuzzed_wallet.GetDestination(fuzzed_data_provider);
88 destination = CNoDestination{script};
94 recipients.push_back({destination,
99 std::optional<unsigned int> change_pos;
101 (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.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
const TestingSetup * g_setup
void ForceSetArg(const std::string &strArg, const std::string &strValue)
uint256 GetBlockHash() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
std::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
std::optional< OutputType > m_change_type
Override the default change type if set, ignored if destChange is set.
bool m_allow_other_inputs
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
std::optional< CFeeRate > m_feerate
Override the wallet's fee rate if set.
bool m_include_unsafe_inputs
If false, only safe inputs will be used.
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
uint32_t m_version
Version.
CTxDestination destChange
Custom change destination, if not set an address is generated.
std::optional< uint32_t > m_locktime
Locktime.
T ConsumeIntegralInRange(T min, T max)
T PickValueInArray(const T(&array)[size])
#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...
static constexpr auto OUTPUT_TYPES
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
std::unique_ptr< interfaces::Chain > chain
Wraps a descriptor wallet for fuzzing.
State of transaction confirmed in a block.
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
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.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.