@@ -6429,34 +6429,6 @@ where
6429
6429
let mut pending_peers_awaiting_removal = Vec::new();
6430
6430
let mut shutdown_channels = Vec::new();
6431
6431
6432
- macro_rules! process_unfunded_channel_tick {
6433
- ($peer_state: expr, $chan: expr, $pending_msg_events: expr) => { {
6434
- let context = &mut $chan.context;
6435
- context.maybe_expire_prev_config();
6436
- if $chan.unfunded_context.should_expire_unfunded_channel() {
6437
- let logger = WithChannelContext::from(&self.logger, context, None);
6438
- log_error!(logger,
6439
- "Force-closing pending channel with ID {} for not establishing in a timely manner",
6440
- context.channel_id());
6441
- let mut close_res = context.force_shutdown(false, ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) });
6442
- locked_close_channel!(self, $peer_state, context, close_res);
6443
- shutdown_channels.push(close_res);
6444
- $pending_msg_events.push(MessageSendEvent::HandleError {
6445
- node_id: context.get_counterparty_node_id(),
6446
- action: msgs::ErrorAction::SendErrorMessage {
6447
- msg: msgs::ErrorMessage {
6448
- channel_id: context.channel_id(),
6449
- data: "Force-closing pending channel due to timeout awaiting establishment handshake".to_owned(),
6450
- },
6451
- },
6452
- });
6453
- false
6454
- } else {
6455
- true
6456
- }
6457
- } }
6458
- }
6459
-
6460
6432
{
6461
6433
let per_peer_state = self.per_peer_state.read().unwrap();
6462
6434
for (counterparty_node_id, peer_state_mutex) in per_peer_state.iter() {
@@ -6465,8 +6437,8 @@ where
6465
6437
let pending_msg_events = &mut peer_state.pending_msg_events;
6466
6438
let counterparty_node_id = *counterparty_node_id;
6467
6439
peer_state.channel_by_id.retain(|chan_id, phase| {
6468
- match phase {
6469
- ChannelPhase::Funded (chan) => {
6440
+ match phase.as_funded_mut() {
6441
+ Some (chan) => {
6470
6442
let new_feerate = if chan.context.get_channel_type().supports_anchors_zero_fee_htlc_tx() {
6471
6443
anchor_feerate
6472
6444
} else {
@@ -6540,14 +6512,32 @@ where
6540
6512
6541
6513
true
6542
6514
},
6543
- ChannelPhase::UnfundedInboundV1(chan) => {
6544
- process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
6545
- },
6546
- ChannelPhase::UnfundedOutboundV1(chan) => {
6547
- process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
6548
- },
6549
- ChannelPhase::UnfundedV2(chan) => {
6550
- process_unfunded_channel_tick!(peer_state, chan, pending_msg_events)
6515
+ None => {
6516
+ phase.context_mut().maybe_expire_prev_config();
6517
+ let unfunded_context = phase.unfunded_context_mut().expect("channel should be unfunded");
6518
+ if unfunded_context.should_expire_unfunded_channel() {
6519
+ let context = phase.context();
6520
+ let logger = WithChannelContext::from(&self.logger, context, None);
6521
+ log_error!(logger,
6522
+ "Force-closing pending channel with ID {} for not establishing in a timely manner",
6523
+ context.channel_id());
6524
+ let context = phase.context_mut();
6525
+ let mut close_res = context.force_shutdown(false, ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) });
6526
+ locked_close_channel!(self, peer_state, context, close_res);
6527
+ shutdown_channels.push(close_res);
6528
+ pending_msg_events.push(MessageSendEvent::HandleError {
6529
+ node_id: context.get_counterparty_node_id(),
6530
+ action: msgs::ErrorAction::SendErrorMessage {
6531
+ msg: msgs::ErrorMessage {
6532
+ channel_id: context.channel_id(),
6533
+ data: "Force-closing pending channel due to timeout awaiting establishment handshake".to_owned(),
6534
+ },
6535
+ },
6536
+ });
6537
+ false
6538
+ } else {
6539
+ true
6540
+ }
6551
6541
},
6552
6542
}
6553
6543
});
0 commit comments