Skip to content

Commit 158d0c1

Browse files
committed
Fix fee addition overflow in get_route
1 parent a331849 commit 158d0c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ln/router.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,9 @@ impl Router {
429429
//TODO: Explore simply adding fee to hit htlc_minimum_msat
430430
if $starting_fee_msat as u64 + final_value_msat > $directional_info.htlc_minimum_msat {
431431
let proportional_fee_millions = ($starting_fee_msat + final_value_msat).checked_mul($directional_info.fee_proportional_millionths as u64);
432-
if let Some(proportional_fee) = proportional_fee_millions {
433-
let new_fee = $directional_info.fee_base_msat as u64 + proportional_fee / 1000000;
432+
if let Some(new_fee) = proportional_fee_millions.and_then(|part| {
433+
($directional_info.fee_base_msat as u64).checked_add(part / 1000000) })
434+
{
434435
let mut total_fee = $starting_fee_msat as u64;
435436
let mut hm_entry = dist.entry(&$directional_info.src_node_id);
436437
let old_entry = hm_entry.or_insert_with(|| {

0 commit comments

Comments
 (0)