Skip to content

Commit 1dda1d0

Browse files
committed
f Rebase on lightningdevkit#596
1 parent 620a6d9 commit 1dda1d0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,9 +3076,13 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
30763076
for (source, payment_hash, value) in timed_out_htlcs.drain(..) {
30773077
// Call it preimage_unknown as the issue, ultimately, is that the user failed to
30783078
// provide us a preimage within the cltv_expiry time window.
3079+
let mut htlc_msat_height_data = byte_utils::be64_to_array(value).to_vec();
3080+
htlc_msat_height_data.extend_from_slice(&byte_utils::be32_to_array(
3081+
self.latest_block_height.load(Ordering::Acquire) as u32,
3082+
));
30793083
self.fail_htlc_backwards_internal(self.channel_state.lock().unwrap(), source, &payment_hash, HTLCFailReason::Reason {
30803084
failure_code: 0x4000 | 15,
3081-
data: byte_utils::be64_to_array(value).to_vec()
3085+
data: htlc_msat_height_data
30823086
});
30833087
}
30843088
self.latest_block_height.store(height as usize, Ordering::Release);

lightning/src/ln/functional_tests.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,11 +3700,22 @@ fn test_htlc_timeout() {
37003700
nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_timeout_updates.update_fail_htlcs[0]);
37013701
commitment_signed_dance!(nodes[0], nodes[1], htlc_timeout_updates.commitment_signed, false);
37023702
let events = nodes[0].node.get_and_clear_pending_events();
3703-
match events[0] {
3704-
Event::PaymentFailed { payment_hash, rejected_by_dest, error_code } => {
3703+
match &events[0] {
3704+
&Event::PaymentFailed { payment_hash, rejected_by_dest, error_code, ref error_data } => {
37053705
assert_eq!(payment_hash, our_payment_hash);
37063706
assert!(rejected_by_dest);
37073707
assert_eq!(error_code.unwrap(), 0x4000 | 15);
3708+
// 100_000 msat as u64, followed by a height of 122 as u32
3709+
assert_eq!(&error_data.as_ref().unwrap()[..], &[
3710+
((100_000u64 >> 7*8) & 0xff) as u8,
3711+
((100_000u64 >> 6*8) & 0xff) as u8,
3712+
((100_000u64 >> 5*8) & 0xff) as u8,
3713+
((100_000u64 >> 4*8) & 0xff) as u8,
3714+
((100_000u64 >> 3*8) & 0xff) as u8,
3715+
((100_000u64 >> 2*8) & 0xff) as u8,
3716+
((100_000u64 >> 1*8) & 0xff) as u8,
3717+
((100_000u64 >> 0*8) & 0xff) as u8,
3718+
0, 0, 0, 122]);
37083719
},
37093720
_ => panic!("Unexpected event"),
37103721
}

0 commit comments

Comments
 (0)