Skip to content

Commit fe8c10d

Browse files
authored
Merge pull request #1077 from jkczyz/2021-09-failing-route-hop
Include short channel id in PaymentPathFailed
2 parents 5a356ca + 202acd9 commit fe8c10d

File tree

6 files changed

+140
-73
lines changed

6 files changed

+140
-73
lines changed

lightning/src/ln/channelmanager.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
30163016
network_update: None,
30173017
all_paths_failed: payment.get().remaining_parts() == 0,
30183018
path: path.clone(),
3019+
short_channel_id: None,
30193020
#[cfg(test)]
30203021
error_code: None,
30213022
#[cfg(test)]
@@ -3069,9 +3070,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
30693070
match &onion_error {
30703071
&HTLCFailReason::LightningError { ref err } => {
30713072
#[cfg(test)]
3072-
let (network_update, payment_retryable, onion_error_code, onion_error_data) = onion_utils::process_onion_failure(&self.secp_ctx, &self.logger, &source, err.data.clone());
3073+
let (network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data) = onion_utils::process_onion_failure(&self.secp_ctx, &self.logger, &source, err.data.clone());
30733074
#[cfg(not(test))]
3074-
let (network_update, payment_retryable, _, _) = onion_utils::process_onion_failure(&self.secp_ctx, &self.logger, &source, err.data.clone());
3075+
let (network_update, short_channel_id, payment_retryable, _, _) = onion_utils::process_onion_failure(&self.secp_ctx, &self.logger, &source, err.data.clone());
30753076
// TODO: If we decided to blame ourselves (or one of our channels) in
30763077
// process_onion_failure we should close that channel as it implies our
30773078
// next-hop is needlessly blaming us!
@@ -3082,6 +3083,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
30823083
network_update,
30833084
all_paths_failed,
30843085
path: path.clone(),
3086+
short_channel_id,
30853087
#[cfg(test)]
30863088
error_code: onion_error_code,
30873089
#[cfg(test)]
@@ -3109,6 +3111,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
31093111
network_update: None,
31103112
all_paths_failed,
31113113
path: path.clone(),
3114+
short_channel_id: Some(path.first().unwrap().short_channel_id),
31123115
#[cfg(test)]
31133116
error_code: Some(*failure_code),
31143117
#[cfg(test)]

lightning/src/ln/functional_tests.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -6075,11 +6075,12 @@ fn test_fail_holding_cell_htlc_upon_free() {
60756075
let events = nodes[0].node.get_and_clear_pending_events();
60766076
assert_eq!(events.len(), 1);
60776077
match &events[0] {
6078-
&Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed, path: _ } => {
6078+
&Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, path: _, ref short_channel_id, ref error_code, ref error_data } => {
60796079
assert_eq!(our_payment_hash.clone(), *payment_hash);
60806080
assert_eq!(*rejected_by_dest, false);
60816081
assert_eq!(*all_paths_failed, true);
60826082
assert_eq!(*network_update, None);
6083+
assert_eq!(*short_channel_id, None);
60836084
assert_eq!(*error_code, None);
60846085
assert_eq!(*error_data, None);
60856086
},
@@ -6162,11 +6163,12 @@ fn test_free_and_fail_holding_cell_htlcs() {
61626163
let events = nodes[0].node.get_and_clear_pending_events();
61636164
assert_eq!(events.len(), 1);
61646165
match &events[0] {
6165-
&Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed, path: _ } => {
6166+
&Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, path: _, ref short_channel_id, ref error_code, ref error_data } => {
61666167
assert_eq!(payment_hash_2.clone(), *payment_hash);
61676168
assert_eq!(*rejected_by_dest, false);
61686169
assert_eq!(*all_paths_failed, true);
61696170
assert_eq!(*network_update, None);
6171+
assert_eq!(*short_channel_id, None);
61706172
assert_eq!(*error_code, None);
61716173
assert_eq!(*error_data, None);
61726174
},

0 commit comments

Comments
 (0)