@@ -1863,6 +1863,7 @@ where
18631863 holder_commitment_point,
18641864 #[cfg(splicing)]
18651865 pending_splice: None,
1866+ quiescent_action: None,
18661867 };
18671868 let res = funded_channel.initial_commitment_signed_v2(msg, best_block, signer_provider, logger)
18681869 .map(|monitor| (Some(monitor), None))
@@ -2429,6 +2430,15 @@ impl PendingSplice {
24292430 }
24302431}
24312432
2433+ pub(crate) enum QuiescentAction {
2434+ // TODO: Make this test-only once we have another variant (as some code requires *a* variant).
2435+ DoNothing,
2436+ }
2437+
2438+ impl_writeable_tlv_based_enum_upgradable!(QuiescentAction,
2439+ (99, DoNothing) => {},
2440+ );
2441+
24322442/// Wrapper around a [`Transaction`] useful for caching the result of [`Transaction::compute_txid`].
24332443struct ConfirmedTransaction<'a> {
24342444 tx: &'a Transaction,
@@ -6050,6 +6060,12 @@ where
60506060 /// Info about an in-progress, pending splice (if any), on the pre-splice channel
60516061 #[cfg(splicing)]
60526062 pending_splice: Option<PendingSplice>,
6063+
6064+ /// Once we become quiescent, if we're the initiator, there's some action we'll want to take.
6065+ /// This keeps track of that action. Note that if we become quiescent and we're not the
6066+ /// initiator we may be able to merge this action into what the counterparty wanted to do (e.g.
6067+ /// in the case of splicing).
6068+ quiescent_action: Option<QuiescentAction>,
60536069}
60546070
60556071#[cfg(splicing)]
@@ -11529,7 +11545,7 @@ where
1152911545 #[cfg(any(test, fuzzing))]
1153011546 #[rustfmt::skip]
1153111547 pub fn propose_quiescence<L: Deref>(
11532- &mut self, logger: &L,
11548+ &mut self, logger: &L, action: QuiescentAction,
1153311549 ) -> Result<Option<msgs::Stfu>, ChannelError>
1153411550 where
1153511551 L::Target: Logger,
@@ -11541,11 +11557,13 @@ where
1154111557 "Channel is not in a live state to propose quiescence".to_owned()
1154211558 ));
1154311559 }
11544- if self.context.channel_state.is_quiescent () {
11545- return Err(ChannelError::Ignore("Channel is already quiescent ".to_owned()));
11560+ if self.quiescent_action.is_some () {
11561+ return Err(ChannelError::Ignore("Channel is already quiescing ".to_owned()));
1154611562 }
1154711563
11548- if self.context.channel_state.is_awaiting_quiescence()
11564+ self.quiescent_action = Some(action);
11565+ if self.context.channel_state.is_quiescent()
11566+ || self.context.channel_state.is_awaiting_quiescence()
1154911567 || self.context.channel_state.is_local_stfu_sent()
1155011568 {
1155111569 return Ok(None);
@@ -11664,6 +11682,21 @@ where
1166411682 if !is_holder_quiescence_initiator { " not" } else { "" }
1166511683 );
1166611684
11685+ if is_holder_quiescence_initiator {
11686+ match self.quiescent_action.take() {
11687+ None => {
11688+ debug_assert!(false);
11689+ return Err(ChannelError::WarnAndDisconnect(
11690+ "Internal Error: Didn't have anything to do after reaching quiescence".to_owned()
11691+ ));
11692+ },
11693+ Some(QuiescentAction::DoNothing) => {
11694+ // In quiescence test we want to just hang out here, letting the test manually
11695+ // leave quiescence.
11696+ },
11697+ }
11698+ }
11699+
1166711700 Ok(None)
1166811701 }
1166911702
@@ -12029,6 +12062,7 @@ where
1202912062 holder_commitment_point,
1203012063 #[cfg(splicing)]
1203112064 pending_splice: None,
12065+ quiescent_action: None,
1203212066 };
1203312067
1203412068 let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
@@ -12315,6 +12349,7 @@ where
1231512349 holder_commitment_point,
1231612350 #[cfg(splicing)]
1231712351 pending_splice: None,
12352+ quiescent_action: None,
1231812353 };
1231912354 let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
1232012355 || channel.context.signer_pending_channel_ready;
@@ -13974,6 +14009,7 @@ where
1397414009 holder_commitment_point,
1397514010 #[cfg(splicing)]
1397614011 pending_splice: None,
14012+ quiescent_action: None,
1397714013 })
1397814014 }
1397914015}
0 commit comments