Use the correct amount when scoring route hints
authorJeffrey Czyz <jkczyz@gmail.com>
Tue, 17 May 2022 21:43:36 +0000 (16:43 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 19 May 2022 19:25:22 +0000 (14:25 -0500)
When scoring route hints, the amount passed to the scorer should include
any fees needed for subsequent hops. This worked correctly for single-
hop hints since there are no further hops, but not for multi-hint hops
(except the final one).

lightning/src/routing/router.rs

index 13cd82f7fc67e91fa025135813fd6dd79876294e..7536011d06d72782672f91ff24a499f1681aa5b4 100644 (file)
@@ -1295,10 +1295,10 @@ where L::Target: Logger {
                                                        short_channel_id: hop.short_channel_id,
                                                })
                                                .unwrap_or_else(|| CandidateRouteHop::PrivateHop { hint: hop });
+                                       let amount_to_transfer_msat = final_value_msat + aggregate_next_hops_fee_msat;
                                        let capacity_msat = candidate.effective_capacity().as_msat();
                                        aggregate_next_hops_path_penalty_msat = aggregate_next_hops_path_penalty_msat
-                                               .saturating_add(scorer.channel_penalty_msat(hop.short_channel_id,
-                                                       final_value_msat, capacity_msat, &source, &target));
+                                               .saturating_add(scorer.channel_penalty_msat(hop.short_channel_id, amount_to_transfer_msat, capacity_msat, &source, &target));
 
                                        aggregate_next_hops_cltv_delta = aggregate_next_hops_cltv_delta
                                                .saturating_add(hop.cltv_expiry_delta as u32);