5 #include <chainparams.h>
18 #include <validation.h>
27 "-testactivationheight=bip34@2",
31 test_setup.LoadVerifyActivateChainstate();
32 auto&
node{test_setup.m_node};
33 auto& chainman{*
Assert(test_setup.m_node.chainman)};
36 const auto ActiveHeight = [&]() {
37 LOCK(chainman.GetMutex());
38 return chainman.ActiveHeight();
40 const auto PrepareNextBlock = [&]() {
53 auto current_block = PrepareNextBlock();
55 std::vector<std::pair<COutPoint, CTxOut>> txos;
63 const auto StoreLastTxo = [&]() {
67 const uint32_t i = tx.
vout.size() - 1;
70 if (current_block->vtx.size() == 1 && tx.
vout.at(i).scriptPubKey[0] ==
OP_RETURN) {
72 const uint32_t i = tx.
vout.size() - 2;
78 tx.vin.emplace_back(txo.first);
79 tx.vout.emplace_back(txo.second.nValue, txo.second.scriptPubKey);
81 const auto UpdateUtxoStats = [&]() {
82 LOCK(chainman.GetMutex());
83 chainman.ActiveChainstate().ForceFlushStateToDisk();
84 utxo_stats = std::move(
94 assert(ActiveHeight() == 0);
100 const CScript duplicate_coinbase_script =
CScript() << duplicate_coinbase_height <<
OP_0;
102 current_block = PrepareNextBlock();
108 tx.
vin.at(0).scriptSig = duplicate_coinbase_script;
117 assert(ActiveHeight() == 1);
119 current_block = PrepareNextBlock();
127 fuzzed_data_provider,
147 const auto prev_utxo_stats = utxo_stats;
149 if (duplicate_coinbase_height == ActiveHeight()) {
151 assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
164 current_block = PrepareNextBlock();
int64_t CAmount
Amount in satoshis (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const uint256 & GetHash() const
T ConsumeIntegralInRange(T min, T max)
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
static bool ComputeUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
void RegenerateCommitments(CBlock &block, ChainstateManager &chainman)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
std::vector< CTxOut > vout
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
std::optional< CAmount > total_amount
The total amount, or nullopt if an overflow occurred calculating it.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
COutPoint MineBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Returns the generated coin.
std::shared_ptr< CBlock > PrepareBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey, const BlockAssembler::Options &assembler_options)
FUZZ_TARGET(utxo_total_supply)
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)