@@ -2874,23 +2874,29 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
2874
2874
let short_to_id = & mut channel_state. short_to_id ;
2875
2875
let pending_msg_events = & mut channel_state. pending_msg_events ;
2876
2876
channel_state. by_id . retain ( |_, channel| {
2877
- let chan_res = channel. block_connected ( header, height, txn_matched, indexes_of_txn_matched) ;
2878
- if let Ok ( Some ( funding_locked) ) = chan_res {
2879
- pending_msg_events. push ( events:: MessageSendEvent :: SendFundingLocked {
2880
- node_id : channel. get_their_node_id ( ) ,
2881
- msg : funding_locked,
2882
- } ) ;
2883
- if let Some ( announcement_sigs) = self . get_announcement_sigs ( channel) {
2884
- log_trace ! ( self , "Sending funding_locked and announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2885
- pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
2877
+ let res = channel. block_connected ( header, height, txn_matched, indexes_of_txn_matched) ;
2878
+ if let Ok ( ( chan_res, mut timed_out_pending_htlcs) ) = res {
2879
+ timed_out_htlcs. reserve ( timed_out_pending_htlcs. len ( ) ) ;
2880
+ for ( htlc_src, payment_hash, value) in timed_out_pending_htlcs. drain ( ..) {
2881
+ timed_out_htlcs. push ( ( htlc_src, payment_hash, value) ) ;
2882
+ }
2883
+ if let Some ( funding_locked) = chan_res {
2884
+ pending_msg_events. push ( events:: MessageSendEvent :: SendFundingLocked {
2886
2885
node_id : channel. get_their_node_id ( ) ,
2887
- msg : announcement_sigs ,
2886
+ msg : funding_locked ,
2888
2887
} ) ;
2889
- } else {
2890
- log_trace ! ( self , "Sending funding_locked WITHOUT announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2888
+ if let Some ( announcement_sigs) = self . get_announcement_sigs ( channel) {
2889
+ log_trace ! ( self , "Sending funding_locked and announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2890
+ pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
2891
+ node_id : channel. get_their_node_id ( ) ,
2892
+ msg : announcement_sigs,
2893
+ } ) ;
2894
+ } else {
2895
+ log_trace ! ( self , "Sending funding_locked WITHOUT announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2896
+ }
2897
+ short_to_id. insert ( channel. get_short_channel_id ( ) . unwrap ( ) , channel. channel_id ( ) ) ;
2891
2898
}
2892
- short_to_id. insert ( channel. get_short_channel_id ( ) . unwrap ( ) , channel. channel_id ( ) ) ;
2893
- } else if let Err ( e) = chan_res {
2899
+ } else if let Err ( e) = res {
2894
2900
pending_msg_events. push ( events:: MessageSendEvent :: HandleError {
2895
2901
node_id : channel. get_their_node_id ( ) ,
2896
2902
action : msgs:: ErrorAction :: SendErrorMessage { msg : e } ,
0 commit comments