Add failed_within_blinded_path to DecodedOnionFailure.
authorValentine Wallace <vwallace@protonmail.com>
Fri, 12 Jan 2024 16:35:08 +0000 (11:35 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 17 Jan 2024 15:44:33 +0000 (10:44 -0500)
Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.

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

index be984858b01f7be0fcbe2b3f1d8463bf6c42dca8..ea6563d445d9161d977dbcd4f76eb1503b98e103 100644 (file)
@@ -429,6 +429,7 @@ pub(crate) struct DecodedOnionFailure {
        pub(crate) network_update: Option<NetworkUpdate>,
        pub(crate) short_channel_id: Option<u64>,
        pub(crate) payment_failed_permanently: bool,
+       pub(crate) failed_within_blinded_path: bool,
        #[cfg(test)]
        pub(crate) onion_error_code: Option<u16>,
        #[cfg(test)]
@@ -725,7 +726,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
                network_update, short_channel_id, payment_failed_permanently, failed_within_blinded_path
        }) = res {
                DecodedOnionFailure {
-                       network_update, short_channel_id, payment_failed_permanently,
+                       network_update, short_channel_id, payment_failed_permanently, failed_within_blinded_path,
                        #[cfg(test)]
                        onion_error_code: error_code_ret,
                        #[cfg(test)]
@@ -736,6 +737,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
                // payment not retryable only when garbage is from the final node
                DecodedOnionFailure {
                        network_update: None, short_channel_id: None, payment_failed_permanently: is_from_final_node,
+                       failed_within_blinded_path: false,
                        #[cfg(test)]
                        onion_error_code: None,
                        #[cfg(test)]
@@ -883,6 +885,7 @@ impl HTLCFailReason {
                                                network_update: None,
                                                payment_failed_permanently: false,
                                                short_channel_id: Some(path.hops[0].short_channel_id),
+                                               failed_within_blinded_path: false,
                                                #[cfg(test)]
                                                onion_error_code: Some(*failure_code),
                                                #[cfg(test)]
index e1748dca7f2ac11978035b2b44c4b66f8a2973d0..e4158a89ada4287bebdfce1689e88442629e848f 100644 (file)
@@ -243,7 +243,7 @@ impl PendingOutboundPayment {
                if insert_res {
                        if let PendingOutboundPayment::Retryable {
                                ref mut pending_amt_msat, ref mut pending_fee_msat,
-                               ref mut remaining_max_total_routing_fee_msat, .. 
+                               ref mut remaining_max_total_routing_fee_msat, ..
                        } = self {
                                        *pending_amt_msat += path.final_value_msat();
                                        let path_fee_msat = path.fee_msat();
@@ -1604,11 +1604,12 @@ impl OutboundPayments {
                #[cfg(test)]
                let DecodedOnionFailure {
                        network_update, short_channel_id, payment_failed_permanently, onion_error_code,
-                       onion_error_data
+                       onion_error_data, failed_within_blinded_path
                } = onion_error.decode_onion_failure(secp_ctx, logger, &source);
                #[cfg(not(test))]
-               let DecodedOnionFailure { network_update, short_channel_id, payment_failed_permanently } =
-                       onion_error.decode_onion_failure(secp_ctx, logger, &source);
+               let DecodedOnionFailure {
+                       network_update, short_channel_id, payment_failed_permanently, failed_within_blinded_path
+               } = onion_error.decode_onion_failure(secp_ctx, logger, &source);
 
                let payment_is_probe = payment_is_probe(payment_hash, &payment_id, probing_cookie_secret);
                let mut session_priv_bytes = [0; 32];