@@ -3293,7 +3293,8 @@ macro_rules! handle_monitor_update_completion {
3293
3293
}
3294
3294
$self.finalize_claims(updates.finalized_claimed_htlcs);
3295
3295
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()) };
3297
3298
$self.fail_htlc_backwards_internal(&failure.0, &failure.1, &failure.2, receiver);
3298
3299
}
3299
3300
} }
@@ -3913,7 +3914,8 @@ where
3913
3914
for htlc_source in failed_htlcs.drain(..) {
3914
3915
let failure_reason = LocalHTLCFailureReason::DroppedPending;
3915
3916
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()) };
3917
3919
self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
3918
3920
}
3919
3921
@@ -4037,7 +4039,8 @@ where
4037
4039
let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
4038
4040
let failure_reason = LocalHTLCFailureReason::DroppedPending;
4039
4041
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()) };
4041
4044
self.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
4042
4045
}
4043
4046
if let Some((_, funding_txo, _channel_id, monitor_update)) = shutdown_res.monitor_update {
@@ -5751,13 +5754,14 @@ where
5751
5754
let mut decode_update_add_htlcs = new_hash_map();
5752
5755
mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());
5753
5756
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 | {
5755
5758
if let Some(outgoing_scid) = outgoing_scid_opt {
5756
5759
match self.short_to_chan_info.read().unwrap().get(&outgoing_scid) {
5757
5760
Some((outgoing_counterparty_node_id, outgoing_channel_id)) =>
5758
5761
HTLCDestination::NextHopChannel {
5759
5762
node_id: Some(*outgoing_counterparty_node_id),
5760
5763
channel_id: *outgoing_channel_id,
5764
+ reason: Some(reason.into()),
5761
5765
},
5762
5766
None => HTLCDestination::UnknownNextHop {
5763
5767
requested_forward_scid: outgoing_scid,
@@ -5819,10 +5823,10 @@ where
5819
5823
Some(Ok(_)) => {},
5820
5824
Some(Err((err, reason))) => {
5821
5825
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() ,
5823
5827
is_intro_node_blinded_forward, &shared_secret,
5824
5828
);
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 );
5826
5830
htlc_fails.push((htlc_fail, htlc_destination));
5827
5831
continue;
5828
5832
},
@@ -5839,7 +5843,7 @@ where
5839
5843
&update_add_htlc, &incoming_counterparty_node_id, err, reason,
5840
5844
is_intro_node_blinded_forward, &shared_secret,
5841
5845
);
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 );
5843
5847
htlc_fails.push((htlc_fail, htlc_destination));
5844
5848
continue;
5845
5849
}
@@ -5851,7 +5855,7 @@ where
5851
5855
) {
5852
5856
Ok(info) => htlc_forwards.push((info, update_add_htlc.htlc_id)),
5853
5857
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 );
5855
5859
htlc_fails.push((self.construct_pending_htlc_fail_msg(&update_add_htlc, &incoming_counterparty_node_id, shared_secret, inbound_err), htlc_destination));
5856
5860
},
5857
5861
}
@@ -6127,7 +6131,11 @@ where
6127
6131
let data = self.get_htlc_inbound_temp_fail_data(reason);
6128
6132
failed_forwards.push((htlc_source, payment_hash,
6129
6133
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
+ }
6131
6139
));
6132
6140
} else {
6133
6141
forwarding_channel_not_found!(core::iter::once(forward_info).chain(draining_pending_forwards));
@@ -6982,8 +6990,12 @@ where
6982
6990
};
6983
6991
6984
6992
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
+ };
6987
6999
self.fail_htlc_backwards_internal(&htlc_src, &payment_hash, &reason, receiver);
6988
7000
}
6989
7001
}
@@ -8768,8 +8780,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8768
8780
}
8769
8781
}
8770
8782
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
+ };
8773
8790
self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
8774
8791
}
8775
8792
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/
9595
9612
} else {
9596
9613
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
9597
9614
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
+ };
9599
9620
let reason = HTLCFailReason::from_failure_code(failure_reason);
9600
9621
self.fail_htlc_backwards_internal(&htlc_update.source, &htlc_update.payment_hash, &reason, receiver);
9601
9622
}
@@ -11689,7 +11710,11 @@ where
11689
11710
let reason = LocalHTLCFailureReason::CLTVExpiryTooSoon;
11690
11711
let data = self.get_htlc_inbound_temp_fail_data(reason);
11691
11712
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
+ }));
11693
11718
}
11694
11719
let logger = WithChannelContext::from(&self.logger, &funded_channel.context, None);
11695
11720
if let Some(channel_ready) = channel_ready_opt {
@@ -14916,7 +14941,7 @@ where
14916
14941
for htlc_source in failed_htlcs.drain(..) {
14917
14942
let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
14918
14943
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()) };
14920
14945
let reason = HTLCFailReason::from_failure_code(failure_reason);
14921
14946
channel_manager.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
14922
14947
}
0 commit comments