Merkle path (BUMP) types and verification — BRC-74 binary format.
A MerklePath associates a transaction with a block via a sequence of hashes at each tree level.
Summary
Functions
Compute the Merkle root given a transaction hash (32 bytes, internal byte order).
Compute root from hex txid string (display order, byte-reversed).
Parse a MerklePath from binary data (BRC-74).
Parse a MerklePath from a hex string.
Serialize to BRC-74 binary format.
Serialize to hex string.
Types
@type t() :: %BSV.SPV.MerklePath{ block_height: non_neg_integer(), path: [[BSV.SPV.MerklePath.PathElement.t()]] }
Functions
Compute the Merkle root given a transaction hash (32 bytes, internal byte order).
If txid is nil, uses the first available hash from level 0.
Validates that duplicate elements only appear at the rightmost position
of each level (mitigates CVE-2012-2459 second preimage attack).
Compute root from hex txid string (display order, byte-reversed).
Parse a MerklePath from binary data (BRC-74).
Returns {:ok, merkle_path, remaining_bytes} so callers (e.g. BEEF parser)
know exactly how many bytes were consumed without re-serialization.
Parse a MerklePath from a hex string.
Serialize to BRC-74 binary format.
Serialize to hex string.