Rename `PaymentSendFailure::AllFailedRetrySafe` `...ResendSafe`
authorMatt Corallo <git@bluematt.me>
Wed, 2 Nov 2022 23:16:25 +0000 (23:16 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 9 Nov 2022 18:44:27 +0000 (18:44 +0000)
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*.

fuzz/src/chanmon_consistency.rs
lightning-invoice/src/payment.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs

index 892e4f6622bafae6cfc0bfd4c300f9bc634dd645..aa6a3faf023fc00ed6688530cd465274bed9ec27 100644 (file)
@@ -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, .. } => {
index 7d5b87cf457def69b76bd94064952aa6f2744799..118ad5da6ef19438df754c2765f8450559ab601d 100644 (file)
@@ -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, .. }) => {
index 63e0bb5ea79a231f95e6f52590739a5c3fdd6420..7de2da89c59a92c6e5dcffb14b9b7d3ae0493203 100644 (file)
@@ -1200,12 +1200,13 @@ pub enum PaymentSendFailure {
        /// send_payment.
        PathParameterError(Vec<Result<(), APIError>>),
        /// 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<APIError>),
+       /// 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<APIError>),
        /// 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<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
                        // `pending_outbound_payments` map, as the user isn't expected to `abandon_payment`.
                        let removed = self.pending_outbound_payments.lock().unwrap().remove(&payment_id).is_some();
                        debug_assert!(removed, "We should always have a pending payment to remove here");
-                       Err(PaymentSendFailure::AllFailedRetrySafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
+                       Err(PaymentSendFailure::AllFailedResendSafe(results.drain(..).map(|r| r.unwrap_err()).collect()))
                } else {
                        Ok(())
                }
index 39a457c8b4a975e04a77e8a0e75b6a1f8a131b2e..5b1b9e22389c75a62bbe351b19440858007888a6 100644 (file)
@@ -587,7 +587,7 @@ macro_rules! get_local_commitment_txn {
 macro_rules! unwrap_send_err {
        ($res: expr, $all_failed: expr, $type: pat, $check: expr) => {
                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 },
index b95356a3dd7aa8b7375118612fe2faa3c2a8b2e7..e60cee80a8a3a8cc0e3f357df8ed9a5643942a08 100644 (file)
@@ -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)),