pub struct Block {
pub header: Header,
pub txdata: Vec<Transaction>,
}
Expand description
Bitcoin block.
A collection of transactions with an attached proof of work.
See Bitcoin Wiki: Block for more information.
Bitcoin Core References
Fields§
§header: Header
The block header
txdata: Vec<Transaction>
List of transactions contained in the block
Implementations§
source§impl Block
impl Block
sourcepub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the block hash.
sourcepub fn check_merkle_root(&self) -> bool
pub fn check_merkle_root(&self) -> bool
Checks if merkle root of header matches merkle root of the transaction list.
sourcepub fn check_witness_commitment(&self) -> bool
pub fn check_witness_commitment(&self) -> bool
Checks if witness commitment in coinbase matches the transaction list.
sourcepub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
pub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
Computes the transaction merkle root.
sourcepub fn compute_witness_commitment(
witness_root: &WitnessMerkleNode,
witness_reserved_value: &[u8]
) -> WitnessCommitment
pub fn compute_witness_commitment( witness_root: &WitnessMerkleNode, witness_reserved_value: &[u8] ) -> WitnessCommitment
Computes the witness commitment for the block’s transaction list.
sourcepub fn witness_root(&self) -> Option<WitnessMerkleNode>
pub fn witness_root(&self) -> Option<WitnessMerkleNode>
Computes the merkle root of transactions hashed for witness.
sourcepub fn weight(&self) -> Weight
pub fn weight(&self) -> Weight
Returns the weight of the block.
Block weight is defined as Base size * 3 + Total size.
sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Returns the total block size.
Total size is the block size in bytes with transactions serialized as described in BIP144, including base data and witness data.
sourcepub fn strippedsize(&self) -> usize
👎Deprecated since 0.31.0: use Block::base_size() instead
pub fn strippedsize(&self) -> usize
Returns the stripped size of the block.
sourcepub fn coinbase(&self) -> Option<&Transaction>
pub fn coinbase(&self) -> Option<&Transaction>
Returns the coinbase transaction, if one is present.
sourcepub fn bip34_block_height(&self) -> Result<u64, Bip34Error>
pub fn bip34_block_height(&self) -> Result<u64, Bip34Error>
Returns the block height, as encoded in the coinbase transaction according to BIP34.