@@ -3293,7 +3293,8 @@ macro_rules! handle_monitor_update_completion {
32933293 }
32943294 $self.finalize_claims(updates.finalized_claimed_htlcs);
32953295 for failure in updates.failed_htlcs.drain(..) {
3296- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
3296+ let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id),
3297+ channel_id, reason: Some(failure.2.clone().into()) };
32973298 $self.fail_htlc_backwards_internal(&failure.0, &failure.1, &failure.2, receiver);
32983299 }
32993300 } }
@@ -3913,7 +3914,8 @@ where
39133914 for htlc_source in failed_htlcs.drain(..) {
39143915 let failure_reason = LocalHTLCFailureReason::DroppedPending;
39153916 let reason = HTLCFailReason::from_failure_code(failure_reason);
3916- let receiver = HTLCDestination::NextHopChannel { node_id: Some(*counterparty_node_id), channel_id: *channel_id };
3917+ let receiver = HTLCDestination::NextHopChannel { node_id: Some(*counterparty_node_id),
3918+ channel_id: *channel_id, reason: Some(failure_reason.into()) };
39173919 self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
39183920 }
39193921
@@ -4037,7 +4039,8 @@ where
40374039 let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
40384040 let failure_reason = LocalHTLCFailureReason::DroppedPending;
40394041 let reason = HTLCFailReason::from_failure_code(failure_reason);
4040- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
4042+ let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id),
4043+ channel_id, reason: Some(failure_reason.into()) };
40414044 self.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
40424045 }
40434046 if let Some((_, funding_txo, _channel_id, monitor_update)) = shutdown_res.monitor_update {
@@ -5751,13 +5754,14 @@ where
57515754 let mut decode_update_add_htlcs = new_hash_map();
57525755 mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());
57535756
5754- let get_failed_htlc_destination = |outgoing_scid_opt: Option<u64>, payment_hash: PaymentHash| {
5757+ let get_failed_htlc_destination = |outgoing_scid_opt: Option<u64>, payment_hash: PaymentHash, reason: LocalHTLCFailureReason | {
57555758 if let Some(outgoing_scid) = outgoing_scid_opt {
57565759 match self.short_to_chan_info.read().unwrap().get(&outgoing_scid) {
57575760 Some((outgoing_counterparty_node_id, outgoing_channel_id)) =>
57585761 HTLCDestination::NextHopChannel {
57595762 node_id: Some(*outgoing_counterparty_node_id),
57605763 channel_id: *outgoing_channel_id,
5764+ reason: Some(reason.into()),
57615765 },
57625766 None => HTLCDestination::UnknownNextHop {
57635767 requested_forward_scid: outgoing_scid,
@@ -5819,10 +5823,10 @@ where
58195823 Some(Ok(_)) => {},
58205824 Some(Err((err, reason))) => {
58215825 let htlc_fail = self.htlc_failure_from_update_add_err(
5822- &update_add_htlc, &incoming_counterparty_node_id, err, reason,
5826+ &update_add_htlc, &incoming_counterparty_node_id, err, reason.clone() ,
58235827 is_intro_node_blinded_forward, &shared_secret,
58245828 );
5825- let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
5829+ let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash, reason );
58265830 htlc_fails.push((htlc_fail, htlc_destination));
58275831 continue;
58285832 },
@@ -5839,7 +5843,7 @@ where
58395843 &update_add_htlc, &incoming_counterparty_node_id, err, reason,
58405844 is_intro_node_blinded_forward, &shared_secret,
58415845 );
5842- let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
5846+ let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash, reason );
58435847 htlc_fails.push((htlc_fail, htlc_destination));
58445848 continue;
58455849 }
@@ -5851,7 +5855,7 @@ where
58515855 ) {
58525856 Ok(info) => htlc_forwards.push((info, update_add_htlc.htlc_id)),
58535857 Err(inbound_err) => {
5854- let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash);
5858+ let htlc_destination = get_failed_htlc_destination(outgoing_scid_opt, update_add_htlc.payment_hash, inbound_err.reason );
58555859 htlc_fails.push((self.construct_pending_htlc_fail_msg(&update_add_htlc, &incoming_counterparty_node_id, shared_secret, inbound_err), htlc_destination));
58565860 },
58575861 }
@@ -6127,7 +6131,11 @@ where
61276131 let data = self.get_htlc_inbound_temp_fail_data(reason);
61286132 failed_forwards.push((htlc_source, payment_hash,
61296133 HTLCFailReason::reason(reason, data),
6130- HTLCDestination::NextHopChannel { node_id: Some(chan.context.get_counterparty_node_id()), channel_id: forward_chan_id }
6134+ HTLCDestination::NextHopChannel {
6135+ node_id: Some(chan.context.get_counterparty_node_id()),
6136+ channel_id: forward_chan_id,
6137+ reason: Some(reason.into()),
6138+ }
61316139 ));
61326140 } else {
61336141 forwarding_channel_not_found!(core::iter::once(forward_info).chain(draining_pending_forwards));
@@ -6982,8 +6990,12 @@ where
69826990 };
69836991
69846992 for (htlc_src, payment_hash) in htlcs_to_fail.drain(..) {
6985- let reason = HTLCFailReason::reason(failure_reason, onion_failure_data.clone());
6986- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id.clone()), channel_id };
6993+ let reason = HTLCFailReason::reason(failure_reason.clone(), onion_failure_data.clone());
6994+ let receiver = HTLCDestination::NextHopChannel {
6995+ node_id: Some(counterparty_node_id.clone()),
6996+ channel_id,
6997+ reason: Some(failure_reason.into()),
6998+ };
69876999 self.fail_htlc_backwards_internal(&htlc_src, &payment_hash, &reason, receiver);
69887000 }
69897001 }
@@ -8768,8 +8780,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
87688780 }
87698781 }
87708782 for htlc_source in dropped_htlcs.drain(..) {
8771- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id.clone()), channel_id: msg.channel_id };
8772- let reason = HTLCFailReason::from_failure_code(LocalHTLCFailureReason::DroppedPending);
8783+ let failure_reason = LocalHTLCFailureReason::DroppedPending;
8784+ let reason = HTLCFailReason::from_failure_code(failure_reason);
8785+ let receiver = HTLCDestination::NextHopChannel {
8786+ node_id: Some(counterparty_node_id.clone()),
8787+ channel_id: msg.channel_id,
8788+ reason: Some(failure_reason.into()),
8789+ };
87738790 self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
87748791 }
87758792 if let Some(shutdown_res) = finish_shutdown {
@@ -9595,7 +9612,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95959612 } else {
95969613 log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
95979614 let failure_reason = LocalHTLCFailureReason::ChannelClosed;
9598- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
9615+ let receiver = HTLCDestination::NextHopChannel {
9616+ node_id: Some(counterparty_node_id),
9617+ channel_id,
9618+ reason: Some(failure_reason.into()),
9619+ };
95999620 let reason = HTLCFailReason::from_failure_code(failure_reason);
96009621 self.fail_htlc_backwards_internal(&htlc_update.source, &htlc_update.payment_hash, &reason, receiver);
96019622 }
@@ -11689,7 +11710,11 @@ where
1168911710 let reason = LocalHTLCFailureReason::CLTVExpiryTooSoon;
1169011711 let data = self.get_htlc_inbound_temp_fail_data(reason);
1169111712 timed_out_htlcs.push((source, payment_hash, HTLCFailReason::reason(reason, data),
11692- HTLCDestination::NextHopChannel { node_id: Some(funded_channel.context.get_counterparty_node_id()), channel_id: funded_channel.context.channel_id() }));
11713+ HTLCDestination::NextHopChannel {
11714+ node_id: Some(funded_channel.context.get_counterparty_node_id()),
11715+ channel_id: funded_channel.context.channel_id(),
11716+ reason: Some(reason.into()),
11717+ }));
1169311718 }
1169411719 let logger = WithChannelContext::from(&self.logger, &funded_channel.context, None);
1169511720 if let Some(channel_ready) = channel_ready_opt {
@@ -14916,7 +14941,7 @@ where
1491614941 for htlc_source in failed_htlcs.drain(..) {
1491714942 let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
1491814943 let failure_reason = LocalHTLCFailureReason::DroppedPending;
14919- let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id };
14944+ let receiver = HTLCDestination::NextHopChannel { node_id: Some(counterparty_node_id), channel_id, reason: Some(failure_reason.into()) };
1492014945 let reason = HTLCFailReason::from_failure_code(failure_reason);
1492114946 channel_manager.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
1492214947 }
0 commit comments