From 9c41f129c0da084e33f6c367b9ab58df3b0fd586 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Thu, 14 Sep 2023 11:33:01 -0400 Subject: [PATCH] DecodedOnionFailure::payment_retryable -> ::payment_failed_permanently 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 | 8 ++++---- lightning/src/ln/outbound_payment.rs | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index db61f0c90..d6bf117e8 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -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, pub(crate) short_channel_id: Option, - pub(crate) payment_retryable: bool, + pub(crate) payment_failed_permanently: bool, #[cfg(test)] pub(crate) onion_error_code: Option, #[cfg(test)] @@ -684,7 +684,7 @@ pub(super) fn process_onion_failure( 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( // 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), diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 5ea772e5d..a4d5c3a38 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -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, -- 2.39.5