We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dfb0deb commit 7b35eb4Copy full SHA for 7b35eb4
crates/fiber-lib/src/cch/actor.rs
@@ -602,9 +602,11 @@ impl<S: CchOrderStore> CchState<S> {
602
return Err(CchError::OutgoingInvoiceExpiryTooShort);
603
}
604
605
- let fee_sats = amount_sats * (self.config.fee_rate_per_million_sats as u128)
606
- / 1_000_000u128
607
- + (self.config.base_fee_sats as u128);
+ let fee_sats = amount_sats
+ .checked_mul(self.config.fee_rate_per_million_sats as u128)
+ .and_then(|v| v.checked_div(1_000_000u128))
608
+ .and_then(|v| v.checked_add(self.config.base_fee_sats as u128))
609
+ .ok_or(CchError::ReceiveBTCOrderAmountTooLarge)?;
610
let total_msat = i64::try_from(
611
amount_sats
612
.checked_add(fee_sats)
0 commit comments