@@ -1935,6 +1935,18 @@ where
1935
1935
let logger = WithChannelContext::from(logger, self.context(), None);
1936
1936
match &mut self.phase {
1937
1937
ChannelPhase::UnfundedV2(chan) => {
1938
+ debug_assert_eq!(
1939
+ chan.context.channel_state,
1940
+ ChannelState::NegotiatingFunding(
1941
+ NegotiatingFundingFlags::OUR_INIT_SENT
1942
+ | NegotiatingFundingFlags::THEIR_INIT_SENT
1943
+ ),
1944
+ );
1945
+
1946
+ chan.context.channel_state =
1947
+ ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
1948
+ chan.context.channel_state.set_interactive_signing();
1949
+
1938
1950
let mut signing_session = chan
1939
1951
.interactive_tx_constructor
1940
1952
.take()
@@ -6071,9 +6083,6 @@ where
6071
6083
funding
6072
6084
.channel_transaction_parameters.funding_outpoint = Some(outpoint);
6073
6085
6074
- self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
6075
- self.channel_state.set_interactive_signing();
6076
-
6077
6086
if is_splice {
6078
6087
debug_assert_eq!(
6079
6088
holder_commitment_transaction_number,
@@ -6121,6 +6130,12 @@ where
6121
6130
SP::Target: SignerProvider,
6122
6131
L::Target: Logger,
6123
6132
{
6133
+ let is_quiescent = matches!(
6134
+ self.channel_state,
6135
+ ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT)
6136
+ );
6137
+ debug_assert!(self.channel_state.is_interactive_signing() || is_quiescent);
6138
+
6124
6139
let mut commitment_number = self.counterparty_next_commitment_transaction_number;
6125
6140
let mut commitment_point = self.counterparty_next_commitment_point.unwrap();
6126
6141
@@ -6167,10 +6182,6 @@ where
6167
6182
SP::Target: SignerProvider,
6168
6183
L::Target: Logger,
6169
6184
{
6170
- assert!(
6171
- matches!(self.channel_state, ChannelState::FundingNegotiated(flags) if flags.is_interactive_signing())
6172
- );
6173
-
6174
6185
let signature = self.get_initial_counterparty_commitment_signature(funding, logger);
6175
6186
if let Some(signature) = signature {
6176
6187
log_info!(
@@ -6201,6 +6212,8 @@ where
6201
6212
SP::Target: SignerProvider,
6202
6213
L::Target: Logger,
6203
6214
{
6215
+ self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
6216
+ self.channel_state.set_interactive_signing();
6204
6217
self.counterparty_next_commitment_point = Some(counterparty_next_commitment_point_override);
6205
6218
self.get_initial_counterparty_commitment_signature(funding, logger)
6206
6219
}
@@ -8581,6 +8594,10 @@ where
8581
8594
format!("Channel {} not expecting funding signatures", self.context.channel_id);
8582
8595
return Err(APIError::APIMisuseError { err });
8583
8596
}
8597
+ debug_assert_eq!(
8598
+ self.has_pending_splice_awaiting_signatures(),
8599
+ matches!(self.context.channel_state, ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT))
8600
+ );
8584
8601
8585
8602
let signing_session =
8586
8603
if let Some(signing_session) = self.interactive_tx_signing_session.as_mut() {
@@ -8631,9 +8648,25 @@ where
8631
8648
.map_err(|err| APIError::APIMisuseError { err })?;
8632
8649
8633
8650
if funding_tx_opt.is_some() {
8634
- self.funding.funding_transaction = funding_tx_opt.clone();
8635
- self.context.channel_state =
8636
- ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8651
+ debug_assert!(tx_signatures_opt.is_some());
8652
+ debug_assert!(!self.context.channel_state.is_monitor_update_in_progress());
8653
+ debug_assert!(!self.context.channel_state.is_awaiting_remote_revoke());
8654
+
8655
+ if let Some(pending_splice) = self.pending_splice.as_mut() {
8656
+ if let Some(FundingNegotiation::AwaitingSignatures(mut funding)) =
8657
+ pending_splice.funding_negotiation.take()
8658
+ {
8659
+ funding.funding_transaction = funding_tx_opt.clone();
8660
+ self.pending_funding.push(funding);
8661
+ } else {
8662
+ debug_assert!(false, "We checked we were in the right state above");
8663
+ }
8664
+ self.context.channel_state.clear_quiescent();
8665
+ } else {
8666
+ self.funding.funding_transaction = funding_tx_opt.clone();
8667
+ self.context.channel_state =
8668
+ ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8669
+ }
8637
8670
}
8638
8671
8639
8672
Ok((tx_signatures_opt, funding_tx_opt))
@@ -8646,6 +8679,10 @@ where
8646
8679
{
8647
8680
return Err(ChannelError::Ignore("Ignoring unexpected tx_signatures".to_owned()));
8648
8681
}
8682
+ debug_assert_eq!(
8683
+ self.has_pending_splice_awaiting_signatures(),
8684
+ matches!(self.context.channel_state, ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT))
8685
+ );
8649
8686
8650
8687
let signing_session = if let Some(signing_session) = self.interactive_tx_signing_session.as_mut() {
8651
8688
if signing_session.has_received_tx_signatures() {
@@ -8678,12 +8715,24 @@ where
8678
8715
.map_err(|msg| ChannelError::Warn(msg))?;
8679
8716
8680
8717
if funding_tx_opt.is_some() {
8681
- // TODO(splicing): Transition back to `ChannelReady` and not `AwaitingChannelReady`
8682
- // We will also need to use the pending `FundingScope` in the splicing case.
8683
- //
8684
- // We have a finalized funding transaction, so we can set the funding transaction.
8685
- self.funding.funding_transaction = funding_tx_opt.clone();
8686
- self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8718
+ debug_assert!(!self.context.channel_state.is_monitor_update_in_progress());
8719
+ debug_assert!(!self.context.channel_state.is_awaiting_remote_revoke());
8720
+
8721
+ if let Some(pending_splice) = self.pending_splice.as_mut() {
8722
+ if let Some(FundingNegotiation::AwaitingSignatures(mut funding)) =
8723
+ pending_splice.funding_negotiation.take()
8724
+ {
8725
+ funding.funding_transaction = funding_tx_opt.clone();
8726
+ self.pending_funding.push(funding);
8727
+ } else {
8728
+ debug_assert!(false, "We checked we were in the right state above");
8729
+ }
8730
+ self.context.channel_state.clear_quiescent();
8731
+ } else {
8732
+ self.funding.funding_transaction = funding_tx_opt.clone();
8733
+ self.context.channel_state =
8734
+ ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8735
+ }
8687
8736
}
8688
8737
8689
8738
Ok((holder_tx_signatures_opt, funding_tx_opt))
0 commit comments