Skip to content

Commit 99ecd02

Browse files
authored
Merge pull request #986 from TheBlueMatt/2021-07-route-lasthop-value
[router] Use the invoice value for last-hop hint channel capacity
2 parents 41d8d4d + 9169dfb commit 99ecd02

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,11 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
882882
htlc_maximum_msat: hop.htlc_maximum_msat,
883883
fees: hop.fees,
884884
};
885-
if add_entry!(hop.short_channel_id, hop.src_node_id, payee, directional_info, None::<u64>, &empty_channel_features, 0, path_value_msat, 0) {
885+
// We assume that the recipient only included route hints for routes which had
886+
// sufficient value to route `final_value_msat`. Note that in the case of "0-value"
887+
// invoices where the invoice does not specify value this may not be the case, but
888+
// better to include the hints than not.
889+
if add_entry!(hop.short_channel_id, hop.src_node_id, payee, directional_info, Some((final_value_msat + 999) / 1000), &empty_channel_features, 0, path_value_msat, 0) {
886890
// If this hop connects to a node with which we have a direct channel,
887891
// ignore the network graph and, if the last hop was added, add our
888892
// direct channel to the candidate set.

0 commit comments

Comments
 (0)