Skip to content

Commit 753e4ce

Browse files
Remove PaymentPathFailed::retry
We now support automatic retries in ChannelManager and no longer support manual retries, so the field is useless.
1 parent 23c1b46 commit 753e4ce

File tree

6 files changed

+15
-58
lines changed

6 files changed

+15
-58
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ mod tests {
13691369
failure: PathFailure::OnPath { network_update: None },
13701370
path: path.clone(),
13711371
short_channel_id: Some(scored_scid),
1372-
retry: None,
13731372
});
13741373
let event = receiver
13751374
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))
@@ -1389,7 +1388,6 @@ mod tests {
13891388
failure: PathFailure::OnPath { network_update: None },
13901389
path: path.clone(),
13911390
short_channel_id: None,
1392-
retry: None,
13931391
});
13941392
let event = receiver
13951393
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,9 +3834,9 @@ where
38343834
// from block_connected which may run during initialization prior to the chain_monitor
38353835
// being fully configured. See the docs for `ChannelManagerReadArgs` for more.
38363836
match source {
3837-
HTLCSource::OutboundRoute { ref path, ref session_priv, ref payment_id, ref payment_params, .. } => {
3837+
HTLCSource::OutboundRoute { ref path, ref session_priv, ref payment_id, .. } => {
38383838
if self.pending_outbound_payments.fail_htlc(source, payment_hash, onion_error, path,
3839-
session_priv, payment_id, payment_params, self.probing_cookie_secret, &self.secp_ctx,
3839+
session_priv, payment_id, self.probing_cookie_secret, &self.secp_ctx,
38403840
&self.pending_events, &self.logger)
38413841
{ self.push_pending_forwards_ev(); }
38423842
},

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,20 +1868,13 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
18681868
) {
18691869
if conditions.expected_mpp_parts_remain { assert_eq!(payment_failed_events.len(), 1); } else { assert_eq!(payment_failed_events.len(), 2); }
18701870
let expected_payment_id = match &payment_failed_events[0] {
1871-
Event::PaymentPathFailed { payment_hash, payment_failed_permanently, path, retry, payment_id, failure, short_channel_id,
1871+
Event::PaymentPathFailed { payment_hash, payment_failed_permanently, payment_id, failure,
18721872
#[cfg(test)]
18731873
error_code,
18741874
#[cfg(test)]
18751875
error_data, .. } => {
18761876
assert_eq!(*payment_hash, expected_payment_hash, "unexpected payment_hash");
18771877
assert_eq!(*payment_failed_permanently, expected_payment_failed_permanently, "unexpected payment_failed_permanently value");
1878-
assert!(retry.is_some(), "expected retry.is_some()");
1879-
assert_eq!(retry.as_ref().unwrap().final_value_msat, path.last().unwrap().fee_msat, "Retry amount should match last hop in path");
1880-
assert_eq!(retry.as_ref().unwrap().payment_params.payee_pubkey, path.last().unwrap().pubkey, "Retry payee node_id should match last hop in path");
1881-
if let Some(scid) = short_channel_id {
1882-
assert!(retry.as_ref().unwrap().payment_params.previously_failed_channels.contains(&scid));
1883-
}
1884-
18851878
#[cfg(test)]
18861879
{
18871880
assert!(error_code.is_some(), "expected error_code.is_some() = true");

lightning/src/ln/outbound_payment.rs

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,6 @@ impl PendingOutboundPayment {
9797
_ => false,
9898
}
9999
}
100-
fn payment_parameters(&mut self) -> Option<&mut PaymentParameters> {
101-
match self {
102-
PendingOutboundPayment::Retryable { payment_params: Some(ref mut params), .. } => {
103-
Some(params)
104-
},
105-
_ => None,
106-
}
107-
}
108100
pub fn insert_previously_failed_scid(&mut self, scid: u64) {
109101
if let PendingOutboundPayment::Retryable { payment_params: Some(params), .. } = self {
110102
params.previously_failed_channels.push(scid);
@@ -798,7 +790,6 @@ impl OutboundPayments {
798790
failure: events::PathFailure::InitialSend { err: e },
799791
path,
800792
short_channel_id: failed_scid,
801-
retry: None,
802793
#[cfg(test)]
803794
error_code: None,
804795
#[cfg(test)]
@@ -1128,8 +1119,8 @@ impl OutboundPayments {
11281119
pub(super) fn fail_htlc<L: Deref>(
11291120
&self, source: &HTLCSource, payment_hash: &PaymentHash, onion_error: &HTLCFailReason,
11301121
path: &Vec<RouteHop>, session_priv: &SecretKey, payment_id: &PaymentId,
1131-
payment_params: &Option<PaymentParameters>, probing_cookie_secret: [u8; 32],
1132-
secp_ctx: &Secp256k1<secp256k1::All>, pending_events: &Mutex<Vec<events::Event>>, logger: &L
1122+
probing_cookie_secret: [u8; 32], secp_ctx: &Secp256k1<secp256k1::All>,
1123+
pending_events: &Mutex<Vec<events::Event>>, logger: &L
11331124
) -> bool where L::Target: Logger {
11341125
#[cfg(test)]
11351126
let (network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data) = onion_error.decode_onion_failure(secp_ctx, logger, &source);
@@ -1157,7 +1148,6 @@ impl OutboundPayments {
11571148

11581149
let mut full_failure_ev = None;
11591150
let mut pending_retry_ev = false;
1160-
let mut retry = None;
11611151
let attempts_remaining = if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(*payment_id) {
11621152
if !payment.get_mut().remove(&session_priv_bytes, Some(&path)) {
11631153
log_trace!(logger, "Received duplicative fail for HTLC with payment_hash {}", log_bytes!(payment_hash.0));
@@ -1169,27 +1159,13 @@ impl OutboundPayments {
11691159
}
11701160
let mut is_retryable_now = payment.get().is_auto_retryable_now();
11711161
if let Some(scid) = short_channel_id {
1162+
// TODO: If we decided to blame ourselves (or one of our channels) in
1163+
// process_onion_failure we should close that channel as it implies our
1164+
// next-hop is needlessly blaming us!
11721165
payment.get_mut().insert_previously_failed_scid(scid);
11731166
}
11741167

1175-
// We want to move towards only using the `PaymentParameters` in the outbound payments
1176-
// map. However, for backwards-compatibility, we still need to support passing the
1177-
// `PaymentParameters` data that was shoved in the HTLC (and given to us via
1178-
// `payment_params`) back to the user.
1179-
let path_last_hop = path.last().expect("Outbound payments must have had a valid path");
1180-
if let Some(params) = payment.get_mut().payment_parameters() {
1181-
retry = Some(RouteParameters {
1182-
payment_params: params.clone(),
1183-
final_value_msat: path_last_hop.fee_msat,
1184-
});
1185-
} else if let Some(params) = payment_params {
1186-
retry = Some(RouteParameters {
1187-
payment_params: params.clone(),
1188-
final_value_msat: path_last_hop.fee_msat,
1189-
});
1190-
}
1191-
1192-
if payment_is_probe || !is_retryable_now || !payment_retryable || retry.is_none() {
1168+
if payment_is_probe || !is_retryable_now || !payment_retryable {
11931169
let _ = payment.get_mut().mark_abandoned(); // we'll only Err if it's a legacy payment
11941170
is_retryable_now = false;
11951171
}
@@ -1229,12 +1205,6 @@ impl OutboundPayments {
12291205
}
12301206
}
12311207
} else {
1232-
// TODO: If we decided to blame ourselves (or one of our channels) in
1233-
// process_onion_failure we should close that channel as it implies our
1234-
// next-hop is needlessly blaming us!
1235-
if let Some(scid) = short_channel_id {
1236-
retry.as_mut().map(|r| r.payment_params.previously_failed_channels.push(scid));
1237-
}
12381208
// If we miss abandoning the payment above, we *must* generate an event here or else the
12391209
// payment will sit in our outbounds forever.
12401210
if attempts_remaining && !already_awaiting_retry {
@@ -1248,7 +1218,6 @@ impl OutboundPayments {
12481218
failure: events::PathFailure::OnPath { network_update },
12491219
path: path.clone(),
12501220
short_channel_id,
1251-
retry,
12521221
#[cfg(test)]
12531222
error_code: onion_error_code,
12541223
#[cfg(test)]

lightning/src/util/events.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,6 @@ pub enum Event {
701701
/// If this is `Some`, then the corresponding channel should be avoided when the payment is
702702
/// retried. May be `None` for older [`Event`] serializations.
703703
short_channel_id: Option<u64>,
704-
/// Parameters used by LDK to compute a new [`Route`] when retrying the failed payment path.
705-
///
706-
/// [`Route`]: crate::routing::router::Route
707-
retry: Option<RouteParameters>,
708704
#[cfg(test)]
709705
error_code: Option<u16>,
710706
#[cfg(test)]
@@ -992,7 +988,7 @@ impl Writeable for Event {
992988
},
993989
&Event::PaymentPathFailed {
994990
ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure,
995-
ref path, ref short_channel_id, ref retry,
991+
ref path, ref short_channel_id,
996992
#[cfg(test)]
997993
ref error_code,
998994
#[cfg(test)]
@@ -1010,7 +1006,7 @@ impl Writeable for Event {
10101006
(3, false, required), // all_paths_failed in LDK versions prior to 0.0.114
10111007
(5, *path, vec_type),
10121008
(7, short_channel_id, option),
1013-
(9, retry, option),
1009+
(9, None::<RouteParameters>, option), // retry in LDK versions prior to 0.0.115
10141010
(11, payment_id, option),
10151011
(13, failure, required),
10161012
});
@@ -1227,7 +1223,6 @@ impl MaybeReadable for Event {
12271223
let mut network_update = None;
12281224
let mut path: Option<Vec<RouteHop>> = Some(vec![]);
12291225
let mut short_channel_id = None;
1230-
let mut retry = None;
12311226
let mut payment_id = None;
12321227
let mut failure_opt = None;
12331228
read_tlv_fields!(reader, {
@@ -1236,7 +1231,6 @@ impl MaybeReadable for Event {
12361231
(2, payment_failed_permanently, required),
12371232
(5, path, vec_type),
12381233
(7, short_channel_id, option),
1239-
(9, retry, option),
12401234
(11, payment_id, option),
12411235
(13, failure_opt, upgradable_option),
12421236
});
@@ -1248,7 +1242,6 @@ impl MaybeReadable for Event {
12481242
failure,
12491243
path: path.unwrap(),
12501244
short_channel_id,
1251-
retry,
12521245
#[cfg(test)]
12531246
error_code,
12541247
#[cfg(test)]

pending_changelog/2063.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## API Updates
2+
3+
- `Event::PaymentPathFailed::retry` will always be `None` if we initiate a payment on 0.0.115
4+
then downgrade to an earlier version (#2063)

0 commit comments

Comments
 (0)