Skip to content

Commit

Permalink
Mempool: make proving work, add a bunch of tests
Browse files Browse the repository at this point in the history
Now, if you call `get_block_proof` for a block whose outputs we have in
our mempool, we'll get a proof for it.

This commit also adds some tests for mempool stuff
  • Loading branch information
Davidson-Souza committed Feb 9, 2025
1 parent a318738 commit 5ead3e8
Show file tree
Hide file tree
Showing 3 changed files with 545 additions and 109 deletions.
22 changes: 22 additions & 0 deletions crates/floresta-chain/src/pruned_utreexo/udata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,26 @@ pub mod proof_util {
EmptyStack,
}

pub fn get_script_type(script: &ScriptBuf) -> ScriptPubkeyType {
if script.is_p2pkh() {
return ScriptPubkeyType::PubKeyHash;
}

if script.is_p2sh() {
return ScriptPubkeyType::ScriptHash;
}

if script.is_p2wpkh() {
return ScriptPubkeyType::WitnessV0PubKeyHash;
}

if script.is_p2wsh() {
return ScriptPubkeyType::WitnessV0ScriptHash;
}

ScriptPubkeyType::Other(script.to_bytes().into_boxed_slice())
}

pub fn reconstruct_leaf_data(
leaf: &CompactLeafData,
input: &TxIn,
Expand Down Expand Up @@ -378,6 +398,8 @@ pub mod proof_util {
.expect("parent_hash: Engines shouldn't be Err")
}

/// From a block, gets the roots that will be included on the acc, certifying
/// that any utxo will not be spend in the same block.
pub fn get_block_adds(
block: &Block,
height: u32,
Expand Down
Loading

0 comments on commit 5ead3e8

Please sign in to comment.