Skip to content

Commit

Permalink
consensus: fix a problem with script sizes (#396)
Browse files Browse the repository at this point in the history
A output's script may be bigger than 10k bytes, it just can't be spent.
We incorrectly check the script pubkey size when it gets created,
causing floresta to break out of consensus if such an output is mined.

Fixes #393
  • Loading branch information
Davidson-Souza authored Mar 6, 2025
1 parent 3b0a243 commit 4284d7d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/floresta-chain/src/pruned_utreexo/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ impl Consensus {
continue;
}

// Sum tx output amounts, check their locking script sizes (scriptpubkey)
let mut out_value = 0;
for output in transaction.output.iter() {
out_value += output.value.to_sat();

Self::validate_script_size(&output.script_pubkey, txid)?;
}
// Sum tx output amounts. This will be used for the fee calculation
let out_value: u64 = transaction
.output
.iter()
.map(|out| out.value.to_sat())
.sum();

// Sum tx input amounts, check their unlocking script sizes (scriptsig and TODO witness)
let mut in_value = 0;
Expand Down

0 comments on commit 4284d7d

Please sign in to comment.