32 std::vector<std::shared_ptr<CBlock>>
ret{total_height};
34 for (
size_t height{0}; height < total_height; ++height) {
35 CBlock& block{*(
ret.at(height) = std::make_shared<CBlock>())};
38 coinbase_tx.
vin.resize(1);
39 coinbase_tx.
vin[0].prevout.SetNull();
40 coinbase_tx.
vout.resize(1);
47 block.hashPrevBlock = (height >= 1 ? *
ret.at(height - 1) : params.
GenesisBlock()).GetHash();
70 bool processed{
Assert(
node.chainman)->ProcessNewBlock(block,
true,
true,
nullptr)};
73 return CTxIn{block->vtx[0]->GetHash(), 0};
77 const BlockAssembler::Options& assembler_options)
79 auto block = std::make_shared<CBlock>(
81 .CreateNewBlock(coinbase_scriptPubKey)
85 block->nTime =
Assert(
node.chainman)->ActiveChain().Tip()->GetMedianTimePast() + 1;
92 BlockAssembler::Options assembler_options;
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
const CBlock & GenesisBlock() const
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
Generate a new block, without valid proof-of-work.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &args, ChainstateManager::Options &opts)
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.
CTxIn MineBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Returns the generated coin.
std::vector< std::shared_ptr< CBlock > > CreateBlockChain(size_t total_height, const CChainParams ¶ms)
Create a blockchain, starting from genesis.
std::shared_ptr< CBlock > PrepareBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey, const BlockAssembler::Options &assembler_options)
CTxIn generatetoaddress(const NodeContext &node, const std::string &address)
RPC-like helper function, returns the generated coin.
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)