Skip to content

Commit bfc0327

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 0df712a commit bfc0327

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

lightning-invoice/src/payment.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,10 @@ pub enum PaymentSendFailure {
12031203
/// You can freely retry 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.
@@ -2707,7 +2708,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
27072708
// `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`.
27082709
let removed = self.pending_outbound_payments.lock().unwrap().remove(&payment_id).is_some();
27092710
debug_assert!(removed, "We should always have a pending payment to remove here");
2710-
Err(PaymentSendFailure::AllFailedRetrySafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
2711+
Err(PaymentSendFailure::AllFailedResendSafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
27112712
} else {
27122713
Ok(())
27132714
}

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ fn test_basic_channel_reserve() {
13321332
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], max_can_send + 1);
13331333
let err = nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).err().unwrap();
13341334
match err {
1335-
PaymentSendFailure::AllFailedRetrySafe(ref fails) => {
1335+
PaymentSendFailure::AllFailedResendSafe(ref fails) => {
13361336
match &fails[0] {
13371337
&APIError::ChannelUnavailable{ref err} =>
13381338
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)