A Bitcoin block consisting of a BSV.BlockHeader and a list of transactions.
Supports parsing from binary/hex, serialization, merkle root calculation, and validation.
Summary
Functions
Calculate the merkle root from the block's transactions.
Parse a block from a binary.
Parse a block from a hex-encoded string.
Check if a block is a genesis block (prev_hash is all zeros).
Return the block hash (delegates to BlockHeader.hash/1).
Return the block hash as a display-order hex string.
Serialize a block to binary.
Serialize a block to a hex-encoded string.
Return the number of transactions in the block.
Validate that the calculated merkle root matches the header's merkle root.
Types
@type t() :: %BSV.Block{header: BSV.BlockHeader.t(), txns: [BSV.Transaction.t()]}
Block struct
Functions
@spec calc_merkle_root(t()) :: <<_::256>>
Calculate the merkle root from the block's transactions.
Parse a block from a binary.
Returns {:ok, block, rest} or {:error, reason}.
Parse a block from a hex-encoded string.
Check if a block is a genesis block (prev_hash is all zeros).
@spec hash(t()) :: <<_::256>>
Return the block hash (delegates to BlockHeader.hash/1).
Return the block hash as a display-order hex string.
Serialize a block to binary.
Serialize a block to a hex-encoded string.
@spec tx_count(t()) :: non_neg_integer()
Return the number of transactions in the block.
Validate that the calculated merkle root matches the header's merkle root.