44 "-testactivationheight=bip34@2",
53 const auto ActiveHeight = [&]() {
54 LOCK(chainman.GetMutex());
55 return chainman.ActiveHeight();
57 const auto PrepareNextBlock = [&]() {
67 block->vtx.back() = MakeTransactionRef(tx);
73 auto current_block = PrepareNextBlock();
75 std::vector<std::pair<COutPoint, CTxOut>> txos;
83 const auto StoreLastTxo = [&]() {
87 const uint32_t i = tx.
vout.size() - 1;
90 if (current_block->vtx.size() == 1 && tx.
vout.at(i).scriptPubKey[0] ==
OP_RETURN) {
92 const uint32_t i = tx.
vout.size() - 2;
98 tx.vin.emplace_back(txo.first);
99 tx.vout.emplace_back(txo.second.nValue, txo.second.scriptPubKey);
101 const auto UpdateUtxoStats = [&](
bool wipe_cache) {
102 LOCK(chainman.GetMutex());
103 chainman.ActiveChainstate().ForceFlushStateToDisk(wipe_cache);
104 utxo_stats = std::move(
113 UpdateUtxoStats(fuzzed_data_provider.
ConsumeBool());
114 assert(ActiveHeight() == 0);
121 CScript duplicate_coinbase_script =
CScript() << duplicate_coinbase_height;
122 if (duplicate_coinbase_height <= 16) {
123 duplicate_coinbase_script <<
OP_0;
126 current_block = PrepareNextBlock();
132 tx.
vin.at(0).scriptSig = duplicate_coinbase_script;
135 current_block->vtx.
front() = MakeTransactionRef(tx);
141 assert(ActiveHeight() == 1);
142 UpdateUtxoStats(fuzzed_data_provider.
ConsumeBool());
143 current_block = PrepareNextBlock();
150 fuzzed_data_provider,
155 current_block->vtx.back() = MakeTransactionRef(tx);
162 current_block->vtx.push_back(MakeTransactionRef(tx));
172 if (duplicate_coinbase_height == ActiveHeight()) {
174 assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
180 UpdateUtxoStats(fuzzed_data_provider.
ConsumeBool());
187 current_block = PrepareNextBlock();
std::unique_ptr< ChainstateManager > chainman