BSV.MerkleProof (BSV v2.1.0) View Source
The MerkleProof module implements the BSV TCS Merkle proof standard.
Merkle proofs are fundamental to the Simplified Payment Verification (SPV)
model that underpins bitcoin scaling. Assuming we have stored block headers
from the blockchain, given a transaction and BSV.MerkleProof.t/0
, we can
verify the transaction is contained in a block without downloading the entire
block.
The TSC Merkle proof standard describes a way of serialising a Merkle proof in a binary or json format, so network participants can share the proofs in a standardised format.
Link to this section Summary
Functions
Calculates and returns the result of hashing all of the transaction hashes contained in the Merkle proof into a tree-like structure known as a Merkle tree.
Parses the given binary into a BSV.MerkleProof.t/0
.
Parses the given binary into a BSV.MerkleProof.t/0
.
Serialises the given BSV.MerkleProof.t/0
into a binary.
Link to this section Types
Specs
t() :: %BSV.MerkleProof{ flags: integer(), index: non_neg_integer(), nodes: [BSV.Tx.hash()], subject: BSV.Tx.t() | BSV.Tx.hash(), target: BSV.BlockHeader.t() | binary() }
Merkle proof struct
Link to this section Functions
Specs
Calculates and returns the result of hashing all of the transaction hashes contained in the Merkle proof into a tree-like structure known as a Merkle tree.
Specs
Parses the given binary into a BSV.MerkleProof.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.
Specs
Parses the given binary into a BSV.MerkleProof.t/0
.
As from_binary/2
but returns the result or raises an exception.
Serialises the given BSV.MerkleProof.t/0
into a binary.
Options
The accepted options are:
:encoding
- Optionally encode the binary with either the:base64
or:hex
encoding scheme.