pub struct Block {
pub header: BlockHeader,
pub txdata: Vec<Transaction>,
}Expand description
A Bitcoin block, which is a collection of transactions with an attached proof of work.
Fields§
§header: BlockHeaderThe 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
check 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 merkle_root(&self) -> Option<TxMerkleNode>
👎Deprecated since 0.28.0: Please use block::compute_merkle_root instead.
pub fn merkle_root(&self) -> Option<TxMerkleNode>
block::compute_merkle_root instead.Calculate 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 get_size(&self) -> usize
👎Deprecated since 0.28.0: Please use block::size instead.
pub fn get_size(&self) -> usize
block::size instead.Returns the size of the block.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of the block.
size == size of header + size of encoded transaction count + total size of transactions.
Sourcepub fn get_strippedsize(&self) -> usize
👎Deprecated since 0.28.0: Please use transaction::strippedsize instead.
pub fn get_strippedsize(&self) -> usize
transaction::strippedsize instead.Returns the strippedsize of the block.
Sourcepub fn strippedsize(&self) -> usize
pub fn strippedsize(&self) -> usize
Returns the strippedsize of the block.
Sourcepub fn get_weight(&self) -> usize
👎Deprecated since 0.28.0: Please use transaction::weight instead.
pub fn get_weight(&self) -> usize
transaction::weight instead.Returns the weight 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Block, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Block, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Block
impl Serialize for Block
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more