Skip to content

Commit e25a892

Browse files
Expose onion_error_code in DecodedOnionFailure in cfg(not(test)).
Will be used to detect when we should cache a blinded payment path as having previously failed to avoid retrying over it.
1 parent 0d513fd commit e25a892

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ pub(crate) struct DecodedOnionFailure {
429429
pub(crate) network_update: Option<NetworkUpdate>,
430430
pub(crate) short_channel_id: Option<u64>,
431431
pub(crate) payment_failed_permanently: bool,
432-
#[cfg(test)]
433432
pub(crate) onion_error_code: Option<u16>,
434433
#[cfg(test)]
435434
pub(crate) onion_error_data: Option<Vec<u8>>,
@@ -721,7 +720,6 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
721720
}) = res {
722721
DecodedOnionFailure {
723722
network_update, short_channel_id, payment_failed_permanently,
724-
#[cfg(test)]
725723
onion_error_code: error_code_ret,
726724
#[cfg(test)]
727725
onion_error_data: error_packet_ret
@@ -731,7 +729,6 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
731729
// payment not retryable only when garbage is from the final node
732730
DecodedOnionFailure {
733731
network_update: None, short_channel_id: None, payment_failed_permanently: is_from_final_node,
734-
#[cfg(test)]
735732
onion_error_code: None,
736733
#[cfg(test)]
737734
onion_error_data: None
@@ -878,7 +875,6 @@ impl HTLCFailReason {
878875
network_update: None,
879876
payment_failed_permanently: false,
880877
short_channel_id: Some(path.hops[0].short_channel_id),
881-
#[cfg(test)]
882878
onion_error_code: Some(*failure_code),
883879
#[cfg(test)]
884880
onion_error_data: Some(data.clone()),

lightning/src/ln/outbound_payment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,8 +1607,9 @@ impl OutboundPayments {
16071607
onion_error_data
16081608
} = onion_error.decode_onion_failure(secp_ctx, logger, &source);
16091609
#[cfg(not(test))]
1610-
let DecodedOnionFailure { network_update, short_channel_id, payment_failed_permanently } =
1611-
onion_error.decode_onion_failure(secp_ctx, logger, &source);
1610+
let DecodedOnionFailure {
1611+
network_update, short_channel_id, payment_failed_permanently, onion_error_code,
1612+
} = onion_error.decode_onion_failure(secp_ctx, logger, &source);
16121613

16131614
let payment_is_probe = payment_is_probe(payment_hash, &payment_id, probing_cookie_secret);
16141615
let mut session_priv_bytes = [0; 32];

0 commit comments

Comments
 (0)