An 80-byte block header providing a summary of a Bitcoin block.
Contains the version, previous block hash, merkle root, timestamp, difficulty target (bits), and nonce. The block hash is the double-SHA256 of the serialized 80-byte header.
Summary
Functions
Parse a block header from a binary.
Parse a block header from a hex-encoded string.
Compute the block hash (double SHA-256 of the 80-byte header), returned as a 32-byte binary in internal byte order (little-endian, as used in Bitcoin's wire protocol).
Compute the block hash as a hex string in display byte order (reversed, as shown in block explorers).
Return the size in bytes of a serialized block header (always 80).
Serialize a block header to its 80-byte binary representation.
Serialize a block header to a hex-encoded string.
Types
@type t() :: %BSV.BlockHeader{ bits: non_neg_integer(), merkle_root: <<_::256>>, nonce: non_neg_integer(), prev_hash: <<_::256>>, time: non_neg_integer(), version: non_neg_integer() }
Block header
Functions
Parse a block header from a binary.
Returns {:ok, header, rest} or {:error, reason}.
Parse a block header from a hex-encoded string.
@spec hash(t()) :: <<_::256>>
Compute the block hash (double SHA-256 of the 80-byte header), returned as a 32-byte binary in internal byte order (little-endian, as used in Bitcoin's wire protocol).
Compute the block hash as a hex string in display byte order (reversed, as shown in block explorers).
@spec size() :: 80
Return the size in bytes of a serialized block header (always 80).
Serialize a block header to its 80-byte binary representation.
Serialize a block header to a hex-encoded string.