30 std::vector<std::shared_ptr<CBlock>> ret{total_height};
32 for (
size_t height{0}; height < total_height; ++height) {
33 CBlock& block{*(ret.at(height) = std::make_shared<CBlock>())};
36 coinbase_tx.
vin.resize(1);
37 coinbase_tx.
vin[0].prevout.SetNull();
38 coinbase_tx.
vout.resize(1);
45 block.hashPrevBlock = (height >= 1 ? *ret.at(height - 1) : params.
GenesisBlock()).GetHash();
68 bool processed{
Assert(
node.chainman)->ProcessNewBlock(
Params(), block,
true,
nullptr)};
71 return CTxIn{block->vtx[0]->GetHash(), 0};
76 auto block = std::make_shared<CBlock>(
78 .CreateNewBlock(coinbase_scriptPubKey)
82 block->nTime =
Assert(
node.chainman)->ActiveChain().Tip()->GetMedianTimePast() + 1;
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Generate a new block, without valid proof-of-work.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const CBlock & GenesisBlock() const
const Consensus::Params & GetConsensus() const
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
A mutable version of CTransaction.
std::vector< CTxOut > vout
NodeContext struct containing references to chain state and connection state.
std::shared_ptr< CBlock > PrepareBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Prepare a block to be mined.
CTxIn MineBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Returns the generated coin.
CTxIn generatetoaddress(const NodeContext &node, const std::string &address)
RPC-like helper function, returns the generated coin.
std::vector< std::shared_ptr< CBlock > > CreateBlockChain(size_t total_height, const CChainParams ¶ms)
Create a blockchain, starting from genesis.
static const CScript P2WSH_OP_TRUE
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
static const int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION
What block version to use for new blocks (pre versionbits)