]> git.bitcoin.ninja Git - rust-lightning/commitdiff
DecodedOnionFailure::payment_retryable -> ::payment_failed_permanently
authorValentine Wallace <vwallace@protonmail.com>
Thu, 14 Sep 2023 15:33:01 +0000 (11:33 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Fri, 22 Sep 2023 19:56:23 +0000 (15:56 -0400)
Our ultimate goal with this field is to set
PaymentPathFailed::payment_failed_permanently, so use this name rather than
flipping a bool back and forth across methods.

lightning/src/ln/onion_utils.rs
lightning/src/ln/outbound_payment.rs

index db61f0c90d00530eaf6a6e612ad837d7244beac2..d6bf117e8146f512821e6b09befdc99336e8ac84 100644 (file)
@@ -426,7 +426,7 @@ pub(super) fn build_first_hop_failure_packet(shared_secret: &[u8], failure_type:
 pub(crate) struct DecodedOnionFailure {
        pub(crate) network_update: Option<NetworkUpdate>,
        pub(crate) short_channel_id: Option<u64>,
-       pub(crate) payment_retryable: bool,
+       pub(crate) payment_failed_permanently: bool,
        #[cfg(test)]
        pub(crate) onion_error_code: Option<u16>,
        #[cfg(test)]
@@ -684,7 +684,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
                network_update, short_channel_id, payment_failed_permanently
        }) = res {
                DecodedOnionFailure {
-                       network_update, short_channel_id, payment_retryable: !payment_failed_permanently,
+                       network_update, short_channel_id, payment_failed_permanently,
                        #[cfg(test)]
                        onion_error_code: error_code_ret,
                        #[cfg(test)]
@@ -694,7 +694,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
                // only not set either packet unparseable or hmac does not match with any
                // payment not retryable only when garbage is from the final node
                DecodedOnionFailure {
-                       network_update: None, short_channel_id: None, payment_retryable: !is_from_final_node,
+                       network_update: None, short_channel_id: None, payment_failed_permanently: is_from_final_node,
                        #[cfg(test)]
                        onion_error_code: None,
                        #[cfg(test)]
@@ -838,7 +838,7 @@ impl HTLCFailReason {
                                if let &HTLCSource::OutboundRoute { ref path, .. } = htlc_source {
                                        DecodedOnionFailure {
                                                network_update: None,
-                                               payment_retryable: true,
+                                               payment_failed_permanently: false,
                                                short_channel_id: Some(path.hops[0].short_channel_id),
                                                #[cfg(test)]
                                                onion_error_code: Some(*failure_code),
index 5ea772e5d4ffbfb0b82c9fc19e014781e3219aa0..a4d5c3a389e4e476dabcfb735aeed05f106e84ce 100644 (file)
@@ -1484,10 +1484,11 @@ impl OutboundPayments {
        ) -> bool where L::Target: Logger {
                #[cfg(test)]
                let DecodedOnionFailure {
-                       network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data
+                       network_update, short_channel_id, payment_failed_permanently, onion_error_code,
+                       onion_error_data
                } = onion_error.decode_onion_failure(secp_ctx, logger, &source);
                #[cfg(not(test))]
-               let DecodedOnionFailure { network_update, short_channel_id, payment_retryable } =
+               let DecodedOnionFailure { network_update, short_channel_id, payment_failed_permanently } =
                        onion_error.decode_onion_failure(secp_ctx, logger, &source);
 
                let payment_is_probe = payment_is_probe(payment_hash, &payment_id, probing_cookie_secret);
@@ -1528,8 +1529,8 @@ impl OutboundPayments {
                                payment.get_mut().insert_previously_failed_scid(scid);
                        }
 
-                       if payment_is_probe || !is_retryable_now || !payment_retryable {
-                               let reason = if !payment_retryable {
+                       if payment_is_probe || !is_retryable_now || payment_failed_permanently {
+                               let reason = if payment_failed_permanently {
                                        PaymentFailureReason::RecipientRejected
                                } else {
                                        PaymentFailureReason::RetriesExhausted
@@ -1559,7 +1560,7 @@ impl OutboundPayments {
 
                let path_failure = {
                        if payment_is_probe {
-                               if !payment_retryable {
+                               if payment_failed_permanently {
                                        events::Event::ProbeSuccessful {
                                                payment_id: *payment_id,
                                                payment_hash: payment_hash.clone(),
@@ -1583,7 +1584,7 @@ impl OutboundPayments {
                                events::Event::PaymentPathFailed {
                                        payment_id: Some(*payment_id),
                                        payment_hash: payment_hash.clone(),
-                                       payment_failed_permanently: !payment_retryable,
+                                       payment_failed_permanently,
                                        failure: events::PathFailure::OnPath { network_update },
                                        path: path.clone(),
                                        short_channel_id,