CBlock

A full block, extending the header with its transactions and cached check flags.

Synopsis

Declared in <primitives/block.h>

class CBlock
    : public CBlockHeader

Base Classes

NameDescription
CBlockHeaderNodes collect new transactions into a block, hash them into a hash tree, and scan through nonce values to make the block's hash satisfy proof-of-work requirements. When they solve the proof-of-work, they broadcast the block to everyone and the block is added to the block chain. The first transaction in the block is a special one that creates a new coin owned by the creator of the block.

Member Functions

NameDescription
CBlock [constructor]Constructors
GetBlockTime Returns the block creation time.
GetHash Computes the block hash by hashing the serialized header.
IsNull Returns true when the header has no proof-of-work target set.
SetNull Resets the block to its null state, clearing transactions and cached flags.
Time Returns the block time as a chrono time point.
ToString Returns a human-readable description of the block.

Static Member Functions

Name
Ser
Unser

Data Members

NameDescription
fChecked Cached result of CheckBlock() for this block.
hashMerkleRoot Merkle root of the transactions in the block.
hashPrevBlock Hash of the previous block header in the chain.
m_checked_merkle_root Cached result of the Merkle root check for this block.
m_checked_witness_commitment Cached result of the witness commitment check for this block.
nBits Compact representation of the proof-of-work difficulty target.
nNonce Nonce varied during mining to satisfy the proof-of-work target.
nTime Block creation time, as a Unix timestamp in seconds.
nVersion Block version number, signaling supported consensus rules.
vtx Transactions contained in the block, in order.

Non-Member Functions

NameDescription
BlockMerkleRootCompute the Merkle root of the transactions in a block. *mutated is set to true if a duplicated subtree was found.
BlockWitnessMerkleRootCompute the Merkle root of the witness transactions in a block.
CheckBlockContext-independent validity checks.
CheckSignetBlockSolutionExtract signature and check whether a block has a valid solution
DecodeHexBlkDecode a hex-encoded serialized block.
DecodeHexBlockHeaderDecode a hex-encoded serialized block header.
GetBlockProofCompute how much work a block header corresponds to.
GetWitnessCommitmentIndexCompute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found
IsBlockMutatedCheck if a block has been mutated (with respect to its merkle root and witness commitments).
TransactionMerklePathCompute merkle path to the specified transaction
node::AddMerkleRootAndCoinbaseInsert the coinbase transaction and compute the merkle root of a block.
node::RegenerateCommitmentsUpdate an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed
node::UpdateTimeUpdate a block header's time field and return the new time.