Skip to content

Commit 23ef253

Browse files
Store previously failed blinded paths on outbound payment failure.
Useful so we don't retry over these paths.
1 parent 5c5d691 commit 23ef253

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1919
use crate::ln::channelmanager::{ChannelDetails, EventCompletionAction, HTLCSource, PaymentId};
2020
use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
2121
use crate::offers::invoice::Bolt12Invoice;
22-
use crate::routing::router::{InFlightHtlcs, Path, PaymentParameters, Route, RouteParameters, Router};
22+
use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, PaymentParameters, Route, RouteParameters, Router};
2323
use crate::util::errors::APIError;
2424
use crate::util::logger::Logger;
2525
use crate::util::time::Time;
@@ -129,6 +129,11 @@ impl PendingOutboundPayment {
129129
params.previously_failed_channels.push(scid);
130130
}
131131
}
132+
pub fn insert_previously_failed_blinded_path(&mut self, blinded_tail: &BlindedTail) {
133+
if let PendingOutboundPayment::Retryable { payment_params: Some(params), .. } = self {
134+
params.insert_previously_failed_blinded_path(blinded_tail);
135+
}
136+
}
132137
fn is_awaiting_invoice(&self) -> bool {
133138
match self {
134139
PendingOutboundPayment::AwaitingInvoice { .. } => true,
@@ -1648,6 +1653,12 @@ impl OutboundPayments {
16481653
// next-hop is needlessly blaming us!
16491654
payment.get_mut().insert_previously_failed_scid(scid);
16501655
}
1656+
if failed_within_blinded_path {
1657+
debug_assert!(short_channel_id.is_none());
1658+
if let Some(bt) = &path.blinded_tail {
1659+
payment.get_mut().insert_previously_failed_blinded_path(&bt);
1660+
} else { debug_assert!(false); }
1661+
}
16511662

16521663
if payment_is_probe || !is_retryable_now || payment_failed_permanently {
16531664
let reason = if payment_failed_permanently {

lightning/src/routing/router.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,19 @@ impl PaymentParameters {
914914
pub fn with_max_channel_saturation_power_of_half(self, max_channel_saturation_power_of_half: u8) -> Self {
915915
Self { max_channel_saturation_power_of_half, ..self }
916916
}
917+
918+
pub(crate) fn insert_previously_failed_blinded_path(&mut self, failed_blinded_tail: &BlindedTail) {
919+
let mut found_blinded_tail = false;
920+
for (idx, (_, path)) in self.payee.blinded_route_hints().iter().enumerate() {
921+
if failed_blinded_tail.hops == path.blinded_hops &&
922+
failed_blinded_tail.blinding_point == path.blinding_point
923+
{
924+
self.previously_failed_blinded_path_idxs.push(idx as u64);
925+
found_blinded_tail = true;
926+
}
927+
}
928+
debug_assert!(found_blinded_tail);
929+
}
917930
}
918931

919932
/// The recipient of a payment, differing based on whether they've hidden their identity with route

0 commit comments

Comments
 (0)