[#CBlock]
= CBlock
:mrdocs:

A full block, extending the header with its transactions and cached check flags&period;

== Synopsis

Declared in `&lt;primitives&sol;block&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CBlock
    : public xref:CBlockHeader.adoc[CBlockHeader]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:CBlockHeader.adoc[CBlockHeader]`
| Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce values to make the block&apos;s hash satisfy proof&hyphen;of&hyphen;work requirements&period; When they solve the proof&hyphen;of&hyphen;work, they broadcast the block to everyone and the block is added to the block chain&period; The first transaction in the block is a special one that creates a new coin owned by the creator of the block&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CBlock/2constructor-06.adoc[`CBlock`]         [.small]#[constructor]#
| Constructors
| xref:CBlockHeader/GetBlockTime.adoc[`GetBlockTime`] 
| Returns the block creation time&period;
| xref:CBlockHeader/GetHash.adoc[`GetHash`] 
| Computes the block hash by hashing the serialized header&period;
| xref:CBlockHeader/IsNull.adoc[`IsNull`] 
| Returns true when the header has no proof&hyphen;of&hyphen;work target set&period;
| xref:CBlock/SetNull.adoc[`SetNull`] 
| Resets the block to its null state, clearing transactions and cached flags&period;
| xref:CBlockHeader/Time.adoc[`Time`] 
| Returns the block time as a chrono time point&period;
| xref:CBlock/ToString.adoc[`ToString`] 
| Returns a human&hyphen;readable description of the block&period;
|===


== Static Member Functions

[cols="1"]
|===
| Name
| xref:CBlock/Ser-06.adoc[`Ser`] 
| xref:CBlock/Unser-0e3.adoc[`Unser`] 
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CBlock/fChecked.adoc[`fChecked`] 
| Cached result of CheckBlock() for this block&period;
| xref:CBlockHeader/hashMerkleRoot.adoc[`hashMerkleRoot`] 
| Merkle root of the transactions in the block&period;
| xref:CBlockHeader/hashPrevBlock.adoc[`hashPrevBlock`] 
| Hash of the previous block header in the chain&period;
| xref:CBlock/m_checked_merkle_root.adoc[`m&lowbar;checked&lowbar;merkle&lowbar;root`] 
| Cached result of the Merkle root check for this block&period;
| xref:CBlock/m_checked_witness_commitment.adoc[`m&lowbar;checked&lowbar;witness&lowbar;commitment`] 
| Cached result of the witness commitment check for this block&period;
| xref:CBlockHeader/nBits.adoc[`nBits`] 
| Compact representation of the proof&hyphen;of&hyphen;work difficulty target&period;
| xref:CBlockHeader/nNonce.adoc[`nNonce`] 
| Nonce varied during mining to satisfy the proof&hyphen;of&hyphen;work target&period;
| xref:CBlockHeader/nTime.adoc[`nTime`] 
| Block creation time, as a Unix timestamp in seconds&period;
| xref:CBlockHeader/nVersion.adoc[`nVersion`] 
| Block version number, signaling supported consensus rules&period;
| xref:CBlock/vtx.adoc[`vtx`] 
| Transactions contained in the block, in order&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BlockMerkleRoot.adoc[`BlockMerkleRoot`]
| Compute the Merkle root of the transactions in a block&period; &ast;mutated is set to true if a duplicated subtree was found&period;
| xref:BlockWitnessMerkleRoot.adoc[`BlockWitnessMerkleRoot`]
| Compute the Merkle root of the witness transactions in a block&period;
| xref:CheckBlock.adoc[`CheckBlock`]
| Context&hyphen;independent validity checks&period;
| xref:CheckSignetBlockSolution.adoc[`CheckSignetBlockSolution`]
| Extract signature and check whether a block has a valid solution
| xref:DecodeHexBlk.adoc[`DecodeHexBlk`]
| Decode a hex&hyphen;encoded serialized block&period;
| xref:DecodeHexBlockHeader.adoc[`DecodeHexBlockHeader`]
| Decode a hex&hyphen;encoded serialized block header&period;
| xref:GetBlockProof-03.adoc[`GetBlockProof`]
| Compute how much work a block header corresponds to&period;
| xref:GetWitnessCommitmentIndex.adoc[`GetWitnessCommitmentIndex`]
| Compute at which vout of the block&apos;s coinbase transaction the witness commitment occurs, or &hyphen;1 if not found
| xref:IsBlockMutated.adoc[`IsBlockMutated`]
| Check if a block has been mutated (with respect to its merkle root and witness commitments)&period;
| xref:TransactionMerklePath.adoc[`TransactionMerklePath`]
| Compute merkle path to the specified transaction
| xref:node/AddMerkleRootAndCoinbase.adoc[`node&colon;&colon;AddMerkleRootAndCoinbase`]
| Insert the coinbase transaction and compute the merkle root of a block&period;
| xref:node/RegenerateCommitments.adoc[`node&colon;&colon;RegenerateCommitments`]
| Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed
| xref:node/UpdateTime.adoc[`node&colon;&colon;UpdateTime`]
| Update a block header&apos;s time field and return the new time&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
