Store previously failed blinded paths on outbound payment failure.
[rust-lightning] / lightning / src / ln / outbound_payment.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 {