Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix an incompatibility between our implementation of is_unpendable and utreexo's #170

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/floresta-chain/src/pruned_utreexo/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use bitcoin::pow::U256;
use bitcoin::Block;
use bitcoin::BlockHash;
use bitcoin::OutPoint;
use bitcoin::ScriptBuf;
use bitcoin::Target;
use bitcoin::Transaction;
use bitcoin::TxOut;
Expand Down Expand Up @@ -228,10 +229,11 @@ impl Consensus {
block_inputs.insert((input.previous_output.txid, input.previous_output.vout));
}
}

// Get all leaf hashes that will be added to the accumulator
for transaction in block.txdata.iter() {
for (i, output) in transaction.output.iter().enumerate() {
if !output.script_pubkey.is_provably_unspendable()
if !Self::is_unspendable(&output.script_pubkey)
&& !block_inputs.contains(&(transaction.txid(), i as u32))
{
leaf_hashes.push(Self::get_leaf_hashes(
Expand All @@ -252,4 +254,16 @@ impl Consensus {
let acc = acc.modify(&hashes, &del_hashes, &proof)?.0;
Ok(acc)
}

fn is_unspendable(script: &ScriptBuf) -> bool {
if script.len() > 10_000 {
return true;
}

if !script.is_empty() && script.as_bytes()[0] == 0x6a {
return true;
}

false
}
}
Loading