@@ -120,6 +120,8 @@ pub(super) enum HTLCForwardInfo {
120
120
AddHTLC {
121
121
prev_short_channel_id : u64 ,
122
122
prev_htlc_id : u64 ,
123
+ prev_channel_outpoint : OutPoint ,
124
+ prev_counterparty_node_id : PublicKey ,
123
125
forward_info : PendingHTLCInfo ,
124
126
} ,
125
127
FailHTLC {
@@ -132,6 +134,8 @@ pub(super) enum HTLCForwardInfo {
132
134
#[ derive( Clone , PartialEq ) ]
133
135
pub ( crate ) struct HTLCPreviousHopData {
134
136
short_channel_id : u64 ,
137
+ outpoint : OutPoint ,
138
+ counterparty_node_id : PublicKey ,
135
139
htlc_id : u64 ,
136
140
incoming_packet_shared_secret : [ u8 ; 32 ] ,
137
141
}
@@ -1554,9 +1558,12 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
1554
1558
failed_forwards. reserve ( pending_forwards. len ( ) ) ;
1555
1559
for forward_info in pending_forwards. drain ( ..) {
1556
1560
match forward_info {
1557
- HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info } => {
1561
+ HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info,
1562
+ prev_channel_outpoint, prev_counterparty_node_id } => {
1558
1563
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
1559
1564
short_channel_id : prev_short_channel_id,
1565
+ outpoint : prev_channel_outpoint,
1566
+ counterparty_node_id : prev_counterparty_node_id,
1560
1567
htlc_id : prev_htlc_id,
1561
1568
incoming_packet_shared_secret : forward_info. incoming_shared_secret ,
1562
1569
} ) ;
@@ -1583,10 +1590,13 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
1583
1590
HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
1584
1591
routing : PendingHTLCRouting :: Forward {
1585
1592
onion_packet, ..
1586
- } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } , } => {
1593
+ } , incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value } ,
1594
+ prev_channel_outpoint, prev_counterparty_node_id } => {
1587
1595
log_trace ! ( self . logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay" , log_bytes!( payment_hash. 0 ) , prev_short_channel_id, short_chan_id) ;
1588
1596
let htlc_source = HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
1589
1597
short_channel_id : prev_short_channel_id,
1598
+ outpoint : prev_channel_outpoint,
1599
+ counterparty_node_id : prev_counterparty_node_id,
1590
1600
htlc_id : prev_htlc_id,
1591
1601
incoming_packet_shared_secret : incoming_shared_secret,
1592
1602
} ) ;
@@ -1701,9 +1711,12 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
1701
1711
match forward_info {
1702
1712
HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info : PendingHTLCInfo {
1703
1713
routing : PendingHTLCRouting :: Receive { payment_data, incoming_cltv_expiry } ,
1704
- incoming_shared_secret, payment_hash, amt_to_forward, .. } , } => {
1714
+ incoming_shared_secret, payment_hash, amt_to_forward, .. } ,
1715
+ prev_channel_outpoint, prev_counterparty_node_id } => {
1705
1716
let prev_hop = HTLCPreviousHopData {
1706
1717
short_channel_id : prev_short_channel_id,
1718
+ outpoint : prev_channel_outpoint,
1719
+ counterparty_node_id : prev_counterparty_node_id,
1707
1720
htlc_id : prev_htlc_id,
1708
1721
incoming_packet_shared_secret : incoming_shared_secret,
1709
1722
} ;
@@ -1738,6 +1751,8 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
1738
1751
) ;
1739
1752
failed_forwards. push ( ( HTLCSource :: PreviousHopData ( HTLCPreviousHopData {
1740
1753
short_channel_id : htlc. prev_hop . short_channel_id ,
1754
+ outpoint : prev_channel_outpoint,
1755
+ counterparty_node_id : prev_counterparty_node_id,
1741
1756
htlc_id : htlc. prev_hop . htlc_id ,
1742
1757
incoming_packet_shared_secret : htlc. prev_hop . incoming_packet_shared_secret ,
1743
1758
} ) , payment_hash,
@@ -1940,7 +1955,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
1940
1955
}
1941
1956
}
1942
1957
} ,
1943
- HTLCSource :: PreviousHopData ( HTLCPreviousHopData { short_channel_id, htlc_id, incoming_packet_shared_secret } ) => {
1958
+ HTLCSource :: PreviousHopData ( HTLCPreviousHopData { short_channel_id, htlc_id, incoming_packet_shared_secret, .. } ) => {
1944
1959
let err_packet = match onion_error {
1945
1960
HTLCFailReason :: Reason { failure_code, data } => {
1946
1961
log_trace ! ( self . logger, "Failing HTLC with payment_hash {} backwards from us with code {}" , log_bytes!( payment_hash. 0 ) , failure_code) ;
@@ -2201,7 +2216,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2201
2216
2202
2217
let ( raa, commitment_update, order, pending_forwards, mut pending_failures, needs_broadcast_safe, funding_locked) = channel. monitor_updating_restored ( & self . logger ) ;
2203
2218
if !pending_forwards. is_empty ( ) {
2204
- htlc_forwards. push ( ( channel. get_short_channel_id ( ) . expect ( "We can't have pending forwards before funding confirmation" ) , pending_forwards) ) ;
2219
+ htlc_forwards. push ( ( channel. get_short_channel_id ( ) . expect ( "We can't have pending forwards before funding confirmation" ) , funding_txo . clone ( ) , channel . get_counterparty_node_id ( ) , pending_forwards) ) ;
2205
2220
}
2206
2221
htlc_failures. append ( & mut pending_failures) ;
2207
2222
@@ -2685,8 +2700,8 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2685
2700
}
2686
2701
2687
2702
#[ inline]
2688
- fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , Vec < ( PendingHTLCInfo , u64 ) > ) ] ) {
2689
- for & mut ( prev_short_channel_id, ref mut pending_forwards) in per_source_pending_forwards {
2703
+ fn forward_htlcs ( & self , per_source_pending_forwards : & mut [ ( u64 , OutPoint , PublicKey , Vec < ( PendingHTLCInfo , u64 ) > ) ] ) {
2704
+ for & mut ( prev_short_channel_id, prev_channel_outpoint , prev_counterparty_node_id , ref mut pending_forwards) in per_source_pending_forwards {
2690
2705
let mut forward_event = None ;
2691
2706
if !pending_forwards. is_empty ( ) {
2692
2707
let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
@@ -2699,10 +2714,12 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2699
2714
PendingHTLCRouting :: Receive { .. } => 0 ,
2700
2715
} ) {
2701
2716
hash_map:: Entry :: Occupied ( mut entry) => {
2702
- entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info } ) ;
2717
+ entry. get_mut ( ) . push ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_channel_outpoint,
2718
+ prev_htlc_id, forward_info, prev_counterparty_node_id } ) ;
2703
2719
} ,
2704
2720
hash_map:: Entry :: Vacant ( entry) => {
2705
- entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_htlc_id, forward_info } ) ) ;
2721
+ entry. insert ( vec ! ( HTLCForwardInfo :: AddHTLC { prev_short_channel_id, prev_channel_outpoint, prev_htlc_id,
2722
+ forward_info, prev_counterparty_node_id } ) ) ;
2706
2723
}
2707
2724
}
2708
2725
}
@@ -2755,18 +2772,19 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
2755
2772
msg,
2756
2773
} ) ;
2757
2774
}
2758
- break Ok ( ( pending_forwards, pending_failures, chan. get ( ) . get_short_channel_id ( ) . expect ( "RAA should only work on a short-id-available channel" ) ) )
2775
+ break Ok ( ( pending_forwards, pending_failures, chan. get ( ) . get_short_channel_id ( ) . expect ( "RAA should only work on a short-id-available channel" ) , chan . get ( ) . get_funding_txo ( ) . unwrap ( ) , chan . get ( ) . get_counterparty_node_id ( ) ) )
2759
2776
} ,
2760
2777
hash_map:: Entry :: Vacant ( _) => break Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
2761
2778
}
2762
2779
} ;
2763
2780
self . fail_holding_cell_htlcs ( htlcs_to_fail, msg. channel_id ) ;
2764
2781
match res {
2765
- Ok ( ( pending_forwards, mut pending_failures, short_channel_id) ) => {
2782
+ Ok ( ( pending_forwards, mut pending_failures, short_channel_id, channel_outpoint,
2783
+ counterparty_node_id) ) => {
2766
2784
for failure in pending_failures. drain ( ..) {
2767
2785
self . fail_htlc_backwards_internal ( self . channel_state . lock ( ) . unwrap ( ) , failure. 0 , & failure. 1 , failure. 2 ) ;
2768
2786
}
2769
- self . forward_htlcs ( & mut [ ( short_channel_id, pending_forwards) ] ) ;
2787
+ self . forward_htlcs ( & mut [ ( short_channel_id, channel_outpoint , counterparty_node_id , pending_forwards) ] ) ;
2770
2788
Ok ( ( ) )
2771
2789
} ,
2772
2790
Err ( e) => Err ( e)
@@ -3543,6 +3561,8 @@ impl Readable for PendingHTLCStatus {
3543
3561
3544
3562
impl_writeable ! ( HTLCPreviousHopData , 0 , {
3545
3563
short_channel_id,
3564
+ outpoint,
3565
+ counterparty_node_id,
3546
3566
htlc_id,
3547
3567
incoming_packet_shared_secret
3548
3568
} ) ;
@@ -3619,9 +3639,11 @@ impl Readable for HTLCFailReason {
3619
3639
impl Writeable for HTLCForwardInfo {
3620
3640
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
3621
3641
match self {
3622
- & HTLCForwardInfo :: AddHTLC { ref prev_short_channel_id, ref prev_htlc_id, ref forward_info } => {
3642
+ & HTLCForwardInfo :: AddHTLC { ref prev_short_channel_id, ref prev_channel_outpoint , ref prev_counterparty_node_id , ref prev_htlc_id, ref forward_info } => {
3623
3643
0u8 . write ( writer) ?;
3624
3644
prev_short_channel_id. write ( writer) ?;
3645
+ prev_channel_outpoint. write ( writer) ?;
3646
+ prev_counterparty_node_id. write ( writer) ?;
3625
3647
prev_htlc_id. write ( writer) ?;
3626
3648
forward_info. write ( writer) ?;
3627
3649
} ,
@@ -3640,6 +3662,8 @@ impl Readable for HTLCForwardInfo {
3640
3662
match <u8 as Readable >:: read ( reader) ? {
3641
3663
0 => Ok ( HTLCForwardInfo :: AddHTLC {
3642
3664
prev_short_channel_id : Readable :: read ( reader) ?,
3665
+ prev_channel_outpoint : Readable :: read ( reader) ?,
3666
+ prev_counterparty_node_id : Readable :: read ( reader) ?,
3643
3667
prev_htlc_id : Readable :: read ( reader) ?,
3644
3668
forward_info : Readable :: read ( reader) ?,
3645
3669
} ) ,
0 commit comments