From: Matt Corallo Date: Wed, 2 Nov 2022 23:16:25 +0000 (+0000) Subject: Rename `PaymentSendFailure::AllFailedRetrySafe` `...ResendSafe` X-Git-Tag: v0.0.113~38^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=c90aac26ad3edf6a3878f63b50c5e9ee425c8f56;p=rust-lightning 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*. --- diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 892e4f662..aa6a3faf0 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -283,7 +283,7 @@ fn check_payment_err(send_err: PaymentSendFailure) { PaymentSendFailure::PathParameterError(per_path_results) => { for res in per_path_results { if let Err(api_err) = res { check_api_err(api_err); } } }, - PaymentSendFailure::AllFailedRetrySafe(per_path_results) => { + PaymentSendFailure::AllFailedResendSafe(per_path_results) => { for api_err in per_path_results { check_api_err(api_err); } }, PaymentSendFailure::PartialFailure { results, .. } => { diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index 7d5b87cf4..118ad5da6 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -543,7 +543,7 @@ where Err(e) => match e { PaymentSendFailure::ParameterError(_) => Err(e), PaymentSendFailure::PathParameterError(_) => Err(e), - PaymentSendFailure::AllFailedRetrySafe(_) => { + PaymentSendFailure::AllFailedResendSafe(_) => { let mut payment_cache = self.payment_cache.lock().unwrap(); let payment_info = payment_cache.get_mut(&payment_hash).unwrap(); payment_info.attempts.count += 1; @@ -655,7 +655,7 @@ where log_trace!(self.logger, "Failed to retry for payment {} due to bogus route/payment data, not retrying.", log_bytes!(payment_hash.0)); Err(()) }, - Err(PaymentSendFailure::AllFailedRetrySafe(_)) => { + Err(PaymentSendFailure::AllFailedResendSafe(_)) => { self.retry_payment(payment_id, payment_hash, params) }, Err(PaymentSendFailure::PartialFailure { failed_paths_retry, results, .. }) => { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 63e0bb5ea..7de2da89c 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1200,12 +1200,13 @@ pub enum PaymentSendFailure { /// send_payment. PathParameterError(Vec>), /// All paths which were attempted failed to send, with no channel state change taking place. - /// You can freely retry the payment in full (though you probably want to do so over different + /// You can freely resend the payment in full (though you probably want to do so over different /// paths than the ones selected). /// - /// [`ChannelManager::abandon_payment`] does *not* need to be called for this payment and - /// [`ChannelManager::retry_payment`] will *not* work for this payment. - AllFailedRetrySafe(Vec), + /// Because the payment failed outright, no payment tracking is done, you do not need to call + /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work + /// for this payment. + AllFailedResendSafe(Vec), /// Some paths which were attempted failed to send, though possibly not all. At least some /// paths have irrevocably committed to the HTLC and retrying the payment in full would result /// in over-/re-payment. @@ -2726,7 +2727,7 @@ impl ChannelManager { match &$res { - &Err(PaymentSendFailure::AllFailedRetrySafe(ref fails)) if $all_failed => { + &Err(PaymentSendFailure::AllFailedResendSafe(ref fails)) if $all_failed => { assert_eq!(fails.len(), 1); match fails[0] { $type => { $check }, diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index b95356a3d..e60cee80a 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -1333,7 +1333,7 @@ fn test_basic_channel_reserve() { let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], max_can_send + 1); let err = nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).err().unwrap(); match err { - PaymentSendFailure::AllFailedRetrySafe(ref fails) => { + PaymentSendFailure::AllFailedResendSafe(ref fails) => { match &fails[0] { &APIError::ChannelUnavailable{ref err} => assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)),