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