From 32ab7a9e4d1200caf5b2e5c9f48c12861dc35fcb Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Tue, 9 Jan 2024 11:52:37 -0500 Subject: [PATCH] Avoid building routes over previously failed blinded payment paths. --- lightning/src/routing/router.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 284bf62f3..c72e5cd9a 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1383,6 +1383,15 @@ impl<'a> CandidateRouteHop<'a> { _ => None, } } + fn blinded_hint_idx(&self) -> Option { + match self { + Self::Blinded(BlindedPathCandidate { hint_idx, .. }) | + Self::OneHopBlinded(OneHopBlindedPathCandidate { hint_idx, .. }) => { + Some(*hint_idx) + }, + _ => None, + } + } /// Returns the source node id of current hop. /// /// Source node id refers to the node forwarding the HTLC through this hop. @@ -2134,8 +2143,15 @@ where L::Target: Logger { (amount_to_transfer_over_msat < $next_hops_path_htlc_minimum_msat && recommended_value_msat >= $next_hops_path_htlc_minimum_msat)); - let payment_failed_on_this_channel = scid_opt.map_or(false, - |scid| payment_params.previously_failed_channels.contains(&scid)); + let payment_failed_on_this_channel = match scid_opt { + Some(scid) => payment_params.previously_failed_channels.contains(&scid), + None => match $candidate.blinded_hint_idx() { + Some(idx) => { + payment_params.previously_failed_blinded_path_idxs.contains(&(idx as u64)) + }, + None => false, + }, + }; let (should_log_candidate, first_hop_details) = match $candidate { CandidateRouteHop::FirstHop(hop) => (true, Some(hop.details)), -- 2.39.5