mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-09 21:23:34 +01:00
Store previously failed blinded paths on outbound payment failure.
Useful so we don't retry over these paths.
This commit is contained in:
parent
5c5d691425
commit
23ef2535d0
2 changed files with 25 additions and 1 deletions
|
@ -19,7 +19,7 @@ use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
|
||||||
use crate::ln::channelmanager::{ChannelDetails, EventCompletionAction, HTLCSource, PaymentId};
|
use crate::ln::channelmanager::{ChannelDetails, EventCompletionAction, HTLCSource, PaymentId};
|
||||||
use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
|
use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
|
||||||
use crate::offers::invoice::Bolt12Invoice;
|
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::errors::APIError;
|
||||||
use crate::util::logger::Logger;
|
use crate::util::logger::Logger;
|
||||||
use crate::util::time::Time;
|
use crate::util::time::Time;
|
||||||
|
@ -129,6 +129,11 @@ impl PendingOutboundPayment {
|
||||||
params.previously_failed_channels.push(scid);
|
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 {
|
fn is_awaiting_invoice(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PendingOutboundPayment::AwaitingInvoice { .. } => true,
|
PendingOutboundPayment::AwaitingInvoice { .. } => true,
|
||||||
|
@ -1648,6 +1653,12 @@ impl OutboundPayments {
|
||||||
// next-hop is needlessly blaming us!
|
// next-hop is needlessly blaming us!
|
||||||
payment.get_mut().insert_previously_failed_scid(scid);
|
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 {
|
if payment_is_probe || !is_retryable_now || payment_failed_permanently {
|
||||||
let reason = if payment_failed_permanently {
|
let reason = if payment_failed_permanently {
|
||||||
|
|
|
@ -914,6 +914,19 @@ impl PaymentParameters {
|
||||||
pub fn with_max_channel_saturation_power_of_half(self, max_channel_saturation_power_of_half: u8) -> Self {
|
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 }
|
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
|
/// The recipient of a payment, differing based on whether they've hidden their identity with route
|
||||||
|
|
Loading…
Add table
Reference in a new issue