From: Matt Corallo Date: Tue, 2 Oct 2018 17:46:03 +0000 (-0400) Subject: Fix Router min HTLC comparison X-Git-Tag: v0.0.12~242^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2018-10-router-htlc-min;p=rust-lightning Fix Router min HTLC comparison --- 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) })