Skip to content

Commit 7b35eb4

Browse files
doitianCopilot
andcommitted
Update crates/fiber-lib/src/cch/actor.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dfb0deb commit 7b35eb4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

crates/fiber-lib/src/cch/actor.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,11 @@ impl<S: CchOrderStore> CchState<S> {
602602
return Err(CchError::OutgoingInvoiceExpiryTooShort);
603603
}
604604

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);
605+
let fee_sats = amount_sats
606+
.checked_mul(self.config.fee_rate_per_million_sats as u128)
607+
.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)?;
608610
let total_msat = i64::try_from(
609611
amount_sats
610612
.checked_add(fee_sats)

0 commit comments

Comments
 (0)