Skip to content

Commit 9c41f12

Browse files
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.
1 parent 61ab1f8 commit 9c41f12

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub(super) fn build_first_hop_failure_packet(shared_secret: &[u8], failure_type:
426426
pub(crate) struct DecodedOnionFailure {
427427
pub(crate) network_update: Option<NetworkUpdate>,
428428
pub(crate) short_channel_id: Option<u64>,
429-
pub(crate) payment_retryable: bool,
429+
pub(crate) payment_failed_permanently: bool,
430430
#[cfg(test)]
431431
pub(crate) onion_error_code: Option<u16>,
432432
#[cfg(test)]
@@ -684,7 +684,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
684684
network_update, short_channel_id, payment_failed_permanently
685685
}) = res {
686686
DecodedOnionFailure {
687-
network_update, short_channel_id, payment_retryable: !payment_failed_permanently,
687+
network_update, short_channel_id, payment_failed_permanently,
688688
#[cfg(test)]
689689
onion_error_code: error_code_ret,
690690
#[cfg(test)]
@@ -694,7 +694,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
694694
// only not set either packet unparseable or hmac does not match with any
695695
// payment not retryable only when garbage is from the final node
696696
DecodedOnionFailure {
697-
network_update: None, short_channel_id: None, payment_retryable: !is_from_final_node,
697+
network_update: None, short_channel_id: None, payment_failed_permanently: is_from_final_node,
698698
#[cfg(test)]
699699
onion_error_code: None,
700700
#[cfg(test)]
@@ -838,7 +838,7 @@ impl HTLCFailReason {
838838
if let &HTLCSource::OutboundRoute { ref path, .. } = htlc_source {
839839
DecodedOnionFailure {
840840
network_update: None,
841-
payment_retryable: true,
841+
payment_failed_permanently: false,
842842
short_channel_id: Some(path.hops[0].short_channel_id),
843843
#[cfg(test)]
844844
onion_error_code: Some(*failure_code),

lightning/src/ln/outbound_payment.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,11 @@ impl OutboundPayments {
14841484
) -> bool where L::Target: Logger {
14851485
#[cfg(test)]
14861486
let DecodedOnionFailure {
1487-
network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data
1487+
network_update, short_channel_id, payment_failed_permanently, onion_error_code,
1488+
onion_error_data
14881489
} = onion_error.decode_onion_failure(secp_ctx, logger, &source);
14891490
#[cfg(not(test))]
1490-
let DecodedOnionFailure { network_update, short_channel_id, payment_retryable } =
1491+
let DecodedOnionFailure { network_update, short_channel_id, payment_failed_permanently } =
14911492
onion_error.decode_onion_failure(secp_ctx, logger, &source);
14921493

14931494
let payment_is_probe = payment_is_probe(payment_hash, &payment_id, probing_cookie_secret);
@@ -1528,8 +1529,8 @@ impl OutboundPayments {
15281529
payment.get_mut().insert_previously_failed_scid(scid);
15291530
}
15301531

1531-
if payment_is_probe || !is_retryable_now || !payment_retryable {
1532-
let reason = if !payment_retryable {
1532+
if payment_is_probe || !is_retryable_now || payment_failed_permanently {
1533+
let reason = if payment_failed_permanently {
15331534
PaymentFailureReason::RecipientRejected
15341535
} else {
15351536
PaymentFailureReason::RetriesExhausted
@@ -1559,7 +1560,7 @@ impl OutboundPayments {
15591560

15601561
let path_failure = {
15611562
if payment_is_probe {
1562-
if !payment_retryable {
1563+
if payment_failed_permanently {
15631564
events::Event::ProbeSuccessful {
15641565
payment_id: *payment_id,
15651566
payment_hash: payment_hash.clone(),
@@ -1583,7 +1584,7 @@ impl OutboundPayments {
15831584
events::Event::PaymentPathFailed {
15841585
payment_id: Some(*payment_id),
15851586
payment_hash: payment_hash.clone(),
1586-
payment_failed_permanently: !payment_retryable,
1587+
payment_failed_permanently,
15871588
failure: events::PathFailure::OnPath { network_update },
15881589
path: path.clone(),
15891590
short_channel_id,

0 commit comments

Comments
 (0)