@@ -3601,8 +3601,15 @@ pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
3601
3601
pub context: ChannelContext<SP>,
3602
3602
#[cfg(any(dual_funding, splicing))]
3603
3603
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
3604
+ /// Number of ticks before channel is force closed if closing_signed negotiation stalls.
3605
+ timer_ticks: i32,
3604
3606
}
3605
3607
3608
+ /// The number of ticks before the channel is forced closed if
3609
+ /// no progress on closing_signed negotiation is being made.
3610
+ /// An unprogressed channel that exceeds this limit will be abandoned.
3611
+ const UNPROGRESS_CLOSING_SIGNED_NEGOTIATION_AGE_LIMIT_TICKS: i32 = 1;
3612
+
3606
3613
#[cfg(any(test, fuzzing))]
3607
3614
struct CommitmentTxInfoCached {
3608
3615
fee: u64,
@@ -5714,7 +5721,7 @@ impl<SP: Deref> Channel<SP> where
5714
5721
if self.closing_negotiation_ready() {
5715
5722
if self.context.closing_signed_in_flight {
5716
5723
return Err(ChannelError::Close("closing_signed negotiation failed to finish within two timer ticks".to_owned()));
5717
- } else {
5724
+ } else if { self.timer_ticks -= 1 ; self.timer_ticks } <= 0 {
5718
5725
self.context.closing_signed_in_flight = true;
5719
5726
}
5720
5727
}
@@ -7790,6 +7797,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7790
7797
context: self.context,
7791
7798
#[cfg(any(dual_funding, splicing))]
7792
7799
dual_funding_channel_context: None,
7800
+ timer_ticks: UNPROGRESS_CLOSING_SIGNED_NEGOTIATION_AGE_LIMIT_TICKS,
7793
7801
};
7794
7802
7795
7803
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
@@ -8080,6 +8088,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
8080
8088
context: self.context,
8081
8089
#[cfg(any(dual_funding, splicing))]
8082
8090
dual_funding_channel_context: None,
8091
+ timer_ticks: UNPROGRESS_CLOSING_SIGNED_NEGOTIATION_AGE_LIMIT_TICKS,
8083
8092
};
8084
8093
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
8085
8094
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -9389,6 +9398,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9389
9398
},
9390
9399
#[cfg(any(dual_funding, splicing))]
9391
9400
dual_funding_channel_context: None,
9401
+ timer_ticks: UNPROGRESS_CLOSING_SIGNED_NEGOTIATION_AGE_LIMIT_TICKS,
9392
9402
})
9393
9403
}
9394
9404
}
0 commit comments