Skip to content

Commit c90aac2

Browse files
committed
Rename PaymentSendFailure::AllFailedRetrySafe ...ResendSafe
It was pointed out that its quite confusing that `AllFailedRetrySafe` does not allow you to call `retry_payment`, though the documentation on it does specify this. Instead, we simply rename it to `AllFailedResendSafe` to indicate that the action that is safe to take is *resending*, not *retrying*.
1 parent 790d26f commit c90aac2

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

fuzz/src/chanmon_consistency.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn check_payment_err(send_err: PaymentSendFailure) {
283283
PaymentSendFailure::PathParameterError(per_path_results) => {
284284
for res in per_path_results { if let Err(api_err) = res { check_api_err(api_err); } }
285285
},
286-
PaymentSendFailure::AllFailedRetrySafe(per_path_results) => {
286+
PaymentSendFailure::AllFailedResendSafe(per_path_results) => {
287287
for api_err in per_path_results { check_api_err(api_err); }
288288
},
289289
PaymentSendFailure::PartialFailure { results, .. } => {

lightning-invoice/src/payment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ where
543543
Err(e) => match e {
544544
PaymentSendFailure::ParameterError(_) => Err(e),
545545
PaymentSendFailure::PathParameterError(_) => Err(e),
546-
PaymentSendFailure::AllFailedRetrySafe(_) => {
546+
PaymentSendFailure::AllFailedResendSafe(_) => {
547547
let mut payment_cache = self.payment_cache.lock().unwrap();
548548
let payment_info = payment_cache.get_mut(&payment_hash).unwrap();
549549
payment_info.attempts.count += 1;
@@ -655,7 +655,7 @@ where
655655
log_trace!(self.logger, "Failed to retry for payment {} due to bogus route/payment data, not retrying.", log_bytes!(payment_hash.0));
656656
Err(())
657657
},
658-
Err(PaymentSendFailure::AllFailedRetrySafe(_)) => {
658+
Err(PaymentSendFailure::AllFailedResendSafe(_)) => {
659659
self.retry_payment(payment_id, payment_hash, params)
660660
},
661661
Err(PaymentSendFailure::PartialFailure { failed_paths_retry, results, .. }) => {

lightning/src/ln/channelmanager.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1200,12 +1200,13 @@ pub enum PaymentSendFailure {
12001200
/// send_payment.
12011201
PathParameterError(Vec<Result<(), APIError>>),
12021202
/// All paths which were attempted failed to send, with no channel state change taking place.
1203-
/// You can freely retry the payment in full (though you probably want to do so over different
1203+
/// You can freely resend the payment in full (though you probably want to do so over different
12041204
/// paths than the ones selected).
12051205
///
1206-
/// [`ChannelManager::abandon_payment`] does *not* need to be called for this payment and
1207-
/// [`ChannelManager::retry_payment`] will *not* work for this payment.
1208-
AllFailedRetrySafe(Vec<APIError>),
1206+
/// Because the payment failed outright, no payment tracking is done, you do not need to call
1207+
/// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1208+
/// for this payment.
1209+
AllFailedResendSafe(Vec<APIError>),
12091210
/// Some paths which were attempted failed to send, though possibly not all. At least some
12101211
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result
12111212
/// in over-/re-payment.
@@ -2726,7 +2727,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
27262727
// `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`.
27272728
let removed = self.pending_outbound_payments.lock().unwrap().remove(&payment_id).is_some();
27282729
debug_assert!(removed, "We should always have a pending payment to remove here");
2729-
Err(PaymentSendFailure::AllFailedRetrySafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
2730+
Err(PaymentSendFailure::AllFailedResendSafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
27302731
} else {
27312732
Ok(())
27322733
}

lightning/src/ln/functional_test_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ macro_rules! get_local_commitment_txn {
587587
macro_rules! unwrap_send_err {
588588
($res: expr, $all_failed: expr, $type: pat, $check: expr) => {
589589
match &$res {
590-
&Err(PaymentSendFailure::AllFailedRetrySafe(ref fails)) if $all_failed => {
590+
&Err(PaymentSendFailure::AllFailedResendSafe(ref fails)) if $all_failed => {
591591
assert_eq!(fails.len(), 1);
592592
match fails[0] {
593593
$type => { $check },

lightning/src/ln/functional_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ fn test_basic_channel_reserve() {
13331333
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], max_can_send + 1);
13341334
let err = nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).err().unwrap();
13351335
match err {
1336-
PaymentSendFailure::AllFailedRetrySafe(ref fails) => {
1336+
PaymentSendFailure::AllFailedResendSafe(ref fails) => {
13371337
match &fails[0] {
13381338
&APIError::ChannelUnavailable{ref err} =>
13391339
assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)),

0 commit comments

Comments
 (0)