BSV.BlockHeader (BSV v2.1.0) View Source

A block header is an 80 byte packet of information providing a summary of the BSV.Block.t/0.

Contained within the block header is a Merkle root - the result of hashing all of the transactions contained in the block into a tree-like structure known as a Merkle tree. Given a transaction and BSV.MerkleProof.t/0, we can verify the transaction is contained in a block without downloading the entire block.

Link to this section Summary

Types

t()

Block header struct

Functions

Parses the given binary into a BSV.BlockHeader.t/0.

Parses the given binary into a BSV.BlockHeader.t/0.

Serialises the given BSV.BlockHeader.t/0 into a binary.

Link to this section Types

Specs

t() :: %BSV.BlockHeader{
  bits: non_neg_integer(),
  merkle_root: BSV.Block.merkle_root(),
  nonce: non_neg_integer(),
  prev_hash: <<_::256>>,
  time: non_neg_integer(),
  version: non_neg_integer()
}

Block header struct

Link to this section Functions

Link to this function

from_binary(data, opts \\ [])

View Source

Specs

from_binary(binary(), keyword()) :: {:ok, t()} | {:error, term()}

Parses the given binary into a BSV.BlockHeader.t/0.

Returns the result in an :ok / :error tuple pair.

Options

The accepted options are:

  • :encoding - Optionally decode the binary with either the :base64 or :hex encoding scheme.
Link to this function

from_binary!(data, opts \\ [])

View Source

Specs

from_binary!(binary(), keyword()) :: t()

Parses the given binary into a BSV.BlockHeader.t/0.

As from_binary/2 but returns the result or raises an exception.

Link to this function

to_binary(header, opts \\ [])

View Source

Serialises the given BSV.BlockHeader.t/0 into a binary.

Options

The accepted options are:

  • :encoding - Optionally encode the binary with either the :base64 or :hex encoding scheme.