From 90027143f05a1a4a5aa0840dabff199e6db95699 Mon Sep 17 00:00:00 2001 From: Boog900 Date: Tue, 10 Sep 2024 01:18:26 +0100 Subject: [PATCH] consensus: misc fixes (#276) * fix decoy checks + fee calculation * fmt --- consensus/src/transactions.rs | 5 +++++ consensus/src/transactions/free.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/consensus/src/transactions.rs b/consensus/src/transactions.rs index 91de67c..09f6884 100644 --- a/consensus/src/transactions.rs +++ b/consensus/src/transactions.rs @@ -393,6 +393,11 @@ async fn verify_transactions_decoy_info( where D: Database + Clone + Sync + Send + 'static, { + // Decoy info is not validated for V1 txs. + if hf == HardFork::V1 || txs.is_empty() { + return Ok(()); + } + batch_get_decoy_info(&txs, hf, database) .await? .try_for_each(|decoy_info| decoy_info.and_then(|di| Ok(check_decoy_info(&di, &hf)?)))?; diff --git a/consensus/src/transactions/free.rs b/consensus/src/transactions/free.rs index 02c5235..67b675a 100644 --- a/consensus/src/transactions/free.rs +++ b/consensus/src/transactions/free.rs @@ -78,7 +78,8 @@ pub fn tx_fee(tx: &Transaction) -> Result { } for output in &prefix.outputs { - fee.checked_sub(output.amount.unwrap_or(0)) + fee = fee + .checked_sub(output.amount.unwrap_or(0)) .ok_or(TransactionError::OutputsTooHigh)?; } }