@@ -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};
46
+ use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UnacceptedChannelContext, UnfundedChannelContext, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel};
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;
@@ -4765,13 +4765,28 @@ where
4765
4765
chan_id: &ChannelId,
4766
4766
context: &mut ChannelContext<SP>,
4767
4767
unfunded_context: &mut UnfundedChannelContext,
4768
+ unaccepted_context: &mut Option<&mut UnacceptedChannelContext>,
4768
4769
pending_msg_events: &mut Vec<MessageSendEvent>,
4769
4770
counterparty_node_id: PublicKey,
4770
4771
| {
4771
4772
context.maybe_expire_prev_config();
4772
- if unfunded_context.should_expire_unfunded_channel() {
4773
- log_error!(self.logger,
4774
- "Force-closing pending channel with ID {} for not establishing in a timely manner", chan_id);
4773
+ let should_expire_unaccepted_channel = match unaccepted_context {
4774
+ Some(unaccepted_context) => unaccepted_context.should_expire_unaccepted_channel(),
4775
+ None => false,
4776
+ };
4777
+ let should_expire_unfunded_channel = unfunded_context.should_expire_unfunded_channel();
4778
+ if should_expire_unaccepted_channel || should_expire_unfunded_channel {
4779
+ let log_msg = if should_expire_unaccepted_channel {
4780
+ format!("Force-closing pending channel with ID {} for not accepting in a timely manner", chan_id)
4781
+ } else {
4782
+ format!("Force-closing pending channel with ID {} for not establishing in a timely manner", chan_id)
4783
+ };
4784
+ let err_msg = if should_expire_unaccepted_channel {
4785
+ "Force-closing pending channel due to timeout awaiting acceptance".to_owned()
4786
+ } else {
4787
+ "Force-closing pending channel due to timeout awaiting establishment handshake".to_owned()
4788
+ };
4789
+ log_error!(self.logger, "{}", log_msg);
4775
4790
update_maps_on_chan_removal!(self, &context);
4776
4791
self.issue_channel_close_events(&context, ClosureReason::HolderForceClosed);
4777
4792
shutdown_channels.push(context.force_shutdown(false));
@@ -4780,7 +4795,7 @@ where
4780
4795
action: msgs::ErrorAction::SendErrorMessage {
4781
4796
msg: msgs::ErrorMessage {
4782
4797
channel_id: *chan_id,
4783
- data: "Force-closing pending channel due to timeout awaiting establishment handshake" .to_owned(),
4798
+ data: err_msg .to_owned(),
4784
4799
},
4785
4800
},
4786
4801
});
@@ -4871,11 +4886,11 @@ where
4871
4886
true
4872
4887
},
4873
4888
ChannelPhase::UnfundedInboundV1(chan) => {
4874
- process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4889
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context, &mut None,
4875
4890
pending_msg_events, counterparty_node_id)
4876
4891
},
4877
4892
ChannelPhase::UnfundedOutboundV1(chan) => {
4878
- process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4893
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context, &mut Some(&mut chan.unaccepted_context),
4879
4894
pending_msg_events, counterparty_node_id)
4880
4895
},
4881
4896
}
@@ -6097,6 +6112,7 @@ where
6097
6112
match phase.get_mut() {
6098
6113
ChannelPhase::UnfundedOutboundV1(chan) => {
6099
6114
try_chan_phase_entry!(self, chan.accept_channel(&msg, &self.default_configuration.channel_handshake_limits, &peer_state.latest_features), phase);
6115
+ chan.unaccepted_context.channel_accepted();
6100
6116
(chan.context.get_value_satoshis(), chan.context.get_funding_redeemscript().to_v0_p2wsh(), chan.context.get_user_id())
6101
6117
},
6102
6118
_ => {
0 commit comments