Expand description
This module provides utility functions for working with Utreexo proofs.
These functions can be used, for example, when verifying if a mempool transaction is valid; to consume a block (delete transactions included in it from the mempool); or to validate a block.
Structs§
- Utreexo
Leaf Error - Error while reconstructing a leaf’s scriptPubKey, returned by
process_proof.
Enums§
- Leaf
Error Kind - Errors that may occur while reconstructing a leaf’s scriptPubKey.
Functions§
- get_
block_ adds - From a block, gets the roots that will be included on the acc, certifying that any utxo will not be spent in the same block.
- get_
leaf_ 🔒hashes - Computes the hash of a leaf node in the utreexo accumulator.
- get_
pk_ 🔒hash - Computes the public key hash from the pushed key in the input’s scriptSig.
- get_
script_ 🔒hash - Computes the script hash from the input’s scriptSig.
- get_
script_ type - This function returns the scriptPubKey type (i.e. address type) of a given script data. It can be:
- get_
witness_ 🔒pk_ hash - Computes the witness public key hash from the input’s witness data.
- get_
witness_ 🔒script_ hash - Computes the witness script hash from the input’s witness data.
- is_
unspendable 🔒 - Checks if a script is unspendable either by its length or if it contains the
OP_RETURNopcode. It follows the implementation on Bitcoin Core. - process_
proof - This function processes a proof of inclusion for a given block.
It takes in the
CompactLeafDatafor this block, this block’s transactions, the height and a function to get the block hash for a given height. Then returns aResultcontaining a vector with hashes for deleted leaves, and aUtxoMap, which is defined asHashMap<OutPoint, UtxoData>. - reconstruct_
leaf_ data - Reconstructs the leaf data from a CompactLeafData, the UTXO’s block hash, and its spending tx input.
- reconstruct_
script_ pubkey - Reconstructs the output script, also called scriptPubKey, from a CompactLeafData and the spending tx input. Returns an error if we can’t reconstruct the script (the input doesn’t contain the required data).
Type Aliases§
- Processed
Proof 🔒 - A processed proof is a tuple containing a vector of deleted leaf hashes and a UTXO map. This will be used to process this block
- UtxoMap 🔒
- A hash map that provides the UTXO data given the outpoint. We will get this data from either our own cache or the Utreexo proofs, and use it to validate blocks and transactions.