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: BlockHeader
The block header
txdata: Vec<Transaction>
List of transactions contained in the block
Implementations
sourceimpl Block
impl Block
sourcepub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Return 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
check if witness commitment in coinbase is matching the transaction list
sourcepub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
pub fn compute_merkle_root(&self) -> Option<TxMerkleNode>
Compute 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>
Please use 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
compute witness commitment for the transaction list
sourcepub fn witness_root(&self) -> Option<WitnessMerkleNode>
pub fn witness_root(&self) -> Option<WitnessMerkleNode>
Merkle root of transactions hashed for witness
sourcepub fn get_strippedsize(&self) -> usize
pub fn get_strippedsize(&self) -> usize
Get the strippedsize of the block
sourcepub fn get_weight(&self) -> usize
pub fn get_weight(&self) -> usize
Get the weight of the block
sourcepub fn coinbase(&self) -> Option<&Transaction>
pub fn coinbase(&self) -> Option<&Transaction>
Get 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>
Get the block height as encoded into the coinbase according to BIP34. Returns None if not present.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Block
impl StructuralEq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more