consensus: misc fixes (#276)

* fix decoy checks + fee calculation

* fmt
This commit is contained in:
Boog900
2024-09-10 01:18:26 +01:00
committed by GitHub
parent 49d1344aa1
commit 90027143f0
2 changed files with 7 additions and 1 deletions

View File

@@ -393,6 +393,11 @@ async fn verify_transactions_decoy_info<D>(
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)?)))?;

View File

@@ -78,7 +78,8 @@ pub fn tx_fee(tx: &Transaction) -> Result<u64, TransactionError> {
}
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)?;
}
}