Module proof_util

Source
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§

UtreexoLeafError
Error while reconstructing a leaf’s scriptPubKey, returned by process_proof.

Enums§

LeafErrorKind
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_script_type
This function returns the scriptPubKey type (i.e. address type) of a given script data. It can be:
process_proof
This function processes a proof of inclusion for a given block. It takes a UData, a slice of transactions, the block height, and a function to get the block hash. It returns a Result containing a Proof, a vector of deleted hashes, and a UtxoMap, which is defined as HashMap<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).