@@ -2814,23 +2814,29 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send> ChainListener for ChannelM
2814
2814
let short_to_id = & mut channel_state. short_to_id ;
2815
2815
let pending_msg_events = & mut channel_state. pending_msg_events ;
2816
2816
channel_state. by_id . retain ( |_, channel| {
2817
- let chan_res = channel. block_connected ( header, height, txn_matched, indexes_of_txn_matched) ;
2818
- if let Ok ( Some ( funding_locked) ) = chan_res {
2819
- pending_msg_events. push ( events:: MessageSendEvent :: SendFundingLocked {
2820
- node_id : channel. get_their_node_id ( ) ,
2821
- msg : funding_locked,
2822
- } ) ;
2823
- if let Some ( announcement_sigs) = self . get_announcement_sigs ( channel) {
2824
- log_trace ! ( self , "Sending funding_locked and announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2825
- pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
2817
+ let res = channel. block_connected ( header, height, txn_matched, indexes_of_txn_matched) ;
2818
+ if let Ok ( ( chan_res, mut timed_out_pending_htlcs) ) = res {
2819
+ timed_out_htlcs. reserve ( timed_out_pending_htlcs. len ( ) ) ;
2820
+ for ( htlc_src, payment_hash, value) in timed_out_pending_htlcs. drain ( ..) {
2821
+ timed_out_htlcs. push ( ( htlc_src, payment_hash, value) ) ;
2822
+ }
2823
+ if let Some ( funding_locked) = chan_res {
2824
+ pending_msg_events. push ( events:: MessageSendEvent :: SendFundingLocked {
2826
2825
node_id : channel. get_their_node_id ( ) ,
2827
- msg : announcement_sigs ,
2826
+ msg : funding_locked ,
2828
2827
} ) ;
2829
- } else {
2830
- log_trace ! ( self , "Sending funding_locked WITHOUT announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2828
+ if let Some ( announcement_sigs) = self . get_announcement_sigs ( channel) {
2829
+ log_trace ! ( self , "Sending funding_locked and announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2830
+ pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
2831
+ node_id : channel. get_their_node_id ( ) ,
2832
+ msg : announcement_sigs,
2833
+ } ) ;
2834
+ } else {
2835
+ log_trace ! ( self , "Sending funding_locked WITHOUT announcement_signatures for {}" , log_bytes!( channel. channel_id( ) ) ) ;
2836
+ }
2837
+ short_to_id. insert ( channel. get_short_channel_id ( ) . unwrap ( ) , channel. channel_id ( ) ) ;
2831
2838
}
2832
- short_to_id. insert ( channel. get_short_channel_id ( ) . unwrap ( ) , channel. channel_id ( ) ) ;
2833
- } else if let Err ( e) = chan_res {
2839
+ } else if let Err ( e) = res {
2834
2840
pending_msg_events. push ( events:: MessageSendEvent :: HandleError {
2835
2841
node_id : channel. get_their_node_id ( ) ,
2836
2842
action : msgs:: ErrorAction :: SendErrorMessage { msg : e } ,
0 commit comments