@@ -80,6 +80,8 @@ use core::ops::Deref;
80
80
pub use crate :: ln:: outbound_payment:: { PaymentSendFailure , Retry , RetryableSendFailure , RecipientOnionFields } ;
81
81
use crate :: ln:: script:: ShutdownScript ;
82
82
83
+ use super :: channel:: UnfundedChannelContext ;
84
+
83
85
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
84
86
//
85
87
// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should
@@ -4410,26 +4412,24 @@ where
4410
4412
true
4411
4413
} ) ;
4412
4414
4413
- let force_close_expired_unfunded_channel = |chan_id : & [ u8 ; 32 ] , chan_context : & mut ChannelContext < <SP :: Target as SignerProvider >:: Signer > | {
4414
- log_error ! ( self . logger, "Force-closing pending outbound channel {} for not establishing in a timely manner" , log_bytes!( & chan_id[ ..] ) ) ;
4415
- self . issue_channel_close_events ( & chan_context, ClosureReason :: HolderForceClosed ) ;
4416
- self . finish_force_close_channel ( chan_context. force_shutdown ( false ) ) ;
4417
- false
4418
- } ;
4419
- peer_state. outbound_v1_channel_by_id . retain ( |chan_id, chan| {
4420
- if chan. pending_context . should_expire_unfunded_channel ( ) {
4421
- force_close_expired_unfunded_channel ( chan_id, & mut chan. context )
4415
+ let process_unfunded_channel_tick = |
4416
+ chan_id : & [ u8 ; 32 ] ,
4417
+ chan_context : & mut ChannelContext < <SP :: Target as SignerProvider >:: Signer > ,
4418
+ unfunded_chan_context : & mut UnfundedChannelContext ,
4419
+ | {
4420
+ chan_context. maybe_expire_prev_config( ) ;
4421
+ if unfunded_chan_context. should_expire_unfunded_channel( ) {
4422
+ log_error ! ( self . logger, "Force-closing pending outbound channel {} for not establishing in a timely manner" , log_bytes!( & chan_id[ ..] ) ) ;
4423
+ update_maps_on_chan_removal ! ( self , & chan_context) ;
4424
+ self . issue_channel_close_events ( & chan_context, ClosureReason :: HolderForceClosed ) ;
4425
+ self . finish_force_close_channel ( chan_context. force_shutdown ( false ) ) ;
4426
+ false
4422
4427
} else {
4423
4428
true
4424
4429
}
4425
- } ) ;
4426
- peer_state. inbound_v1_channel_by_id . retain ( |chan_id, chan| {
4427
- if chan. pending_context . should_expire_unfunded_channel ( ) {
4428
- force_close_expired_unfunded_channel ( chan_id, & mut chan. context )
4429
- } else {
4430
- true
4431
- }
4432
- } ) ;
4430
+ } ;
4431
+ peer_state. outbound_v1_channel_by_id . retain ( |chan_id, chan| process_unfunded_channel_tick ( chan_id, & mut chan. context , & mut chan. unfunded_context ) ) ;
4432
+ peer_state. inbound_v1_channel_by_id . retain ( |chan_id, chan| process_unfunded_channel_tick ( chan_id, & mut chan. context , & mut chan. unfunded_context ) ) ;
4433
4433
4434
4434
if peer_state. ok_to_remove ( true ) {
4435
4435
pending_peers_awaiting_removal. push ( counterparty_node_id) ;
0 commit comments