7#include <chainparams.h>
42 CBlockIndex* pindexPrev = testing_setup->m_node.chainman->ActiveChain().Tip();
43 assert(pindexPrev !=
nullptr);
49 coinbaseTx.
vin.resize(1);
50 coinbaseTx.
vin[0].prevout.SetNull();
51 coinbaseTx.
vout.resize(1);
52 coinbaseTx.
vout[0].scriptPubKey = SCRIPT_PUB;
57 naughtyTx.
vout.resize(1);
58 naughtyTx.
vout[0].nValue = 0;
59 naughtyTx.
vout[0].scriptPubKey = SCRIPT_PUB;
61 uint64_t n_inputs = (((MAX_BLOCK_SERIALIZED_SIZE / WITNESS_SCALE_FACTOR) - (
CTransaction(coinbaseTx).ComputeTotalSize() +
CTransaction(naughtyTx).ComputeTotalSize())) / 41) - 100;
62 for (uint64_t x = 0; x < (n_inputs - 1); ++x) {
65 naughtyTx.
vin.emplace_back(naughtyTx.
vin.back());
67 block.
vtx.push_back(MakeTransactionRef(std::move(coinbaseTx)));
68 block.
vtx.push_back(MakeTransactionRef(std::move(naughtyTx)));
const CChainParams & Params()
Return the currently selected parameters.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
int nHeight
height of the entry in the chain. The genesis block has height 0
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
Serialized script, used inside transaction inputs and outputs.
CTransaction(const CMutableTransaction &tx)
Convert a CMutableTransaction into a CTransaction.
std::string GetRejectReason() const
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
static transaction_identifier FromUint256(const uint256 &id)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
unsigned int GetNextWorkRequired(const CBlockIndex *pindexLast, const CBlockHeader *pblock, const Consensus::Params ¶ms)
uint256 GetRandHash() noexcept
Generate a random uint256.
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.
A mutable version of CTransaction.
std::vector< CTxOut > vout
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
Functions for validating blocks and updating the block tree.