From 4f4a5c06d2edb25f61c1bfe282d4517456a2c2ff Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 2 Oct 2018 13:46:03 -0400 Subject: [PATCH] Fix Router min HTLC comparison --- src/ln/functional_tests.rs | 2 +- src/ln/router.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ln/functional_tests.rs b/src/ln/functional_tests.rs index eeff90e29..551b9de70 100644 --- a/src/ln/functional_tests.rs +++ b/src/ln/functional_tests.rs @@ -6724,7 +6724,7 @@ fn test_update_add_htlc_bolt2_receiver_check_amount_received_more_than_min() { let channel = chan_lock.by_id.get(&chan.2).unwrap(); htlc_minimum_msat = channel.get_our_htlc_minimum_msat(); } - let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &[], htlc_minimum_msat+1, TEST_FINAL_CLTV).unwrap(); + let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &[], htlc_minimum_msat, TEST_FINAL_CLTV).unwrap(); let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]); nodes[0].node.send_payment(route, our_payment_hash).unwrap(); check_added_monitors!(nodes[0], 1); diff --git a/src/ln/router.rs b/src/ln/router.rs index 3920d44fc..12b3e43f5 100644 --- a/src/ln/router.rs +++ b/src/ln/router.rs @@ -708,7 +708,7 @@ impl Router { // $directional_info. ( $chan_id: expr, $dest_node_id: expr, $directional_info: expr, $starting_fee_msat: expr ) => { //TODO: Explore simply adding fee to hit htlc_minimum_msat - if $starting_fee_msat as u64 + final_value_msat > $directional_info.htlc_minimum_msat { + if $starting_fee_msat as u64 + final_value_msat >= $directional_info.htlc_minimum_msat { let proportional_fee_millions = ($starting_fee_msat + final_value_msat).checked_mul($directional_info.fee_proportional_millionths as u64); if let Some(new_fee) = proportional_fee_millions.and_then(|part| { ($directional_info.fee_base_msat as u64).checked_add(part / 1000000) }) -- 2.39.5