@@ -43,7 +43,7 @@ use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, Messa
43
43
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
44
44
// construct one themselves.
45
45
use crate::ln::{inbound_payment, ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};
46
- use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UnfundedChannelContext, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel, WithChannelContext};
46
+ use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UnconfirmedChannelContext, UnfundedChannelContext, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel, WithChannelContext};
47
47
use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
48
48
#[cfg(any(feature = "_test_utils", test))]
49
49
use crate::ln::features::Bolt11InvoiceFeatures;
@@ -4831,14 +4831,20 @@ where
4831
4831
chan_id: &ChannelId,
4832
4832
context: &mut ChannelContext<SP>,
4833
4833
unfunded_context: &mut UnfundedChannelContext,
4834
+ unconfirmed_context: &mut Option<&mut UnconfirmedChannelContext>,
4834
4835
pending_msg_events: &mut Vec<MessageSendEvent>,
4835
4836
counterparty_node_id: PublicKey,
4837
+ is_connected: bool
4836
4838
| {
4837
4839
context.maybe_expire_prev_config();
4838
- if unfunded_context.should_expire_unfunded_channel() {
4840
+ let should_expire_unconfirmed_channel = match unconfirmed_context {
4841
+ Some(unconfirmed_context) => unconfirmed_context.should_expire_unconfirmed_channel(is_connected),
4842
+ None => false,
4843
+ };
4844
+ let should_expire_unfunded_channel = unfunded_context.should_expire_unfunded_channel();
4845
+ if should_expire_unconfirmed_channel || should_expire_unfunded_channel {
4839
4846
let logger = WithChannelContext::from(&self.logger, context);
4840
- log_error!(logger,
4841
- "Force-closing pending channel with ID {} for not establishing in a timely manner", chan_id);
4847
+ log_error!(logger, "Force-closing pending channel with ID {} for not establishing in a timely manner", chan_id);
4842
4848
update_maps_on_chan_removal!(self, &context);
4843
4849
self.issue_channel_close_events(&context, ClosureReason::HolderForceClosed);
4844
4850
shutdown_channels.push(context.force_shutdown(false));
@@ -4847,7 +4853,7 @@ where
4847
4853
action: msgs::ErrorAction::SendErrorMessage {
4848
4854
msg: msgs::ErrorMessage {
4849
4855
channel_id: *chan_id,
4850
- data: "Force-closing pending channel due to timeout awaiting establishment handshake".to_owned(),
4856
+ data: "Force-closing pending channel due to timeout awaiting establishment handshake".to_owned()
4851
4857
},
4852
4858
},
4853
4859
});
@@ -4862,6 +4868,7 @@ where
4862
4868
for (counterparty_node_id, peer_state_mutex) in per_peer_state.iter() {
4863
4869
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
4864
4870
let peer_state = &mut *peer_state_lock;
4871
+ let peer_connected = peer_state.is_connected.clone();
4865
4872
let pending_msg_events = &mut peer_state.pending_msg_events;
4866
4873
let counterparty_node_id = *counterparty_node_id;
4867
4874
peer_state.channel_by_id.retain(|chan_id, phase| {
@@ -4939,12 +4946,12 @@ where
4939
4946
true
4940
4947
},
4941
4948
ChannelPhase::UnfundedInboundV1(chan) => {
4942
- process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4943
- pending_msg_events, counterparty_node_id)
4949
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context, &mut None,
4950
+ pending_msg_events, counterparty_node_id, peer_connected )
4944
4951
},
4945
4952
ChannelPhase::UnfundedOutboundV1(chan) => {
4946
- process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4947
- pending_msg_events, counterparty_node_id)
4953
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context, &mut Some(&mut chan.unconfirmed_context),
4954
+ pending_msg_events, counterparty_node_id, peer_connected )
4948
4955
},
4949
4956
}
4950
4957
});
0 commit comments