Store previously failed blinded paths on outbound payment failure.
authorValentine Wallace <vwallace@protonmail.com>
Tue, 9 Jan 2024 16:32:38 +0000 (11:32 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 17 Jan 2024 15:44:38 +0000 (10:44 -0500)
Useful so we don't retry over these paths.

lightning/src/ln/outbound_payment.rs
lightning/src/routing/router.rs

index e4158a89ada4287bebdfce1689e88442629e848f..47193bea3f197b2fcd41d261202c612c5f06526a 100644 (file)
@@ -19,7 +19,7 @@ use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
 use crate::ln::channelmanager::{ChannelDetails, EventCompletionAction, HTLCSource, PaymentId};
 use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
 use crate::offers::invoice::Bolt12Invoice;
-use crate::routing::router::{InFlightHtlcs, Path, PaymentParameters, Route, RouteParameters, Router};
+use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, PaymentParameters, Route, RouteParameters, Router};
 use crate::util::errors::APIError;
 use crate::util::logger::Logger;
 use crate::util::time::Time;
@@ -129,6 +129,11 @@ impl PendingOutboundPayment {
                        params.previously_failed_channels.push(scid);
                }
        }
+       pub fn insert_previously_failed_blinded_path(&mut self, blinded_tail: &BlindedTail) {
+               if let PendingOutboundPayment::Retryable { payment_params: Some(params), .. } = self {
+                       params.insert_previously_failed_blinded_path(blinded_tail);
+               }
+       }
        fn is_awaiting_invoice(&self) -> bool {
                match self {
                        PendingOutboundPayment::AwaitingInvoice { .. } => true,
@@ -1648,6 +1653,12 @@ impl OutboundPayments {
                                // next-hop is needlessly blaming us!
                                payment.get_mut().insert_previously_failed_scid(scid);
                        }
+                       if failed_within_blinded_path {
+                               debug_assert!(short_channel_id.is_none());
+                               if let Some(bt) = &path.blinded_tail {
+                                       payment.get_mut().insert_previously_failed_blinded_path(&bt);
+                               } else { debug_assert!(false); }
+                       }
 
                        if payment_is_probe || !is_retryable_now || payment_failed_permanently {
                                let reason = if payment_failed_permanently {
index 44933d6746748b05f8f668a314e2e7bbed218acd..284bf62f36e561f1f1793e3d302f0d7d54280175 100644 (file)
@@ -914,6 +914,19 @@ impl PaymentParameters {
        pub fn with_max_channel_saturation_power_of_half(self, max_channel_saturation_power_of_half: u8) -> Self {
                Self { max_channel_saturation_power_of_half, ..self }
        }
+
+       pub(crate) fn insert_previously_failed_blinded_path(&mut self, failed_blinded_tail: &BlindedTail) {
+               let mut found_blinded_tail = false;
+               for (idx, (_, path)) in self.payee.blinded_route_hints().iter().enumerate() {
+                       if failed_blinded_tail.hops == path.blinded_hops &&
+                               failed_blinded_tail.blinding_point == path.blinding_point
+                       {
+                               self.previously_failed_blinded_path_idxs.push(idx as u64);
+                               found_blinded_tail = true;
+                       }
+               }
+               debug_assert!(found_blinded_tail);
+       }
 }
 
 /// The recipient of a payment, differing based on whether they've hidden their identity with route