@@ -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()
@@ -5998,9 +6010,6 @@ where
5998
6010
funding
5999
6011
.channel_transaction_parameters.funding_outpoint = Some(outpoint);
6000
6012
6001
- self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
6002
- self.channel_state.set_interactive_signing();
6003
-
6004
6013
if is_splice {
6005
6014
debug_assert_eq!(
6006
6015
holder_commitment_transaction_number,
@@ -6048,6 +6057,12 @@ where
6048
6057
SP::Target: SignerProvider,
6049
6058
L::Target: Logger,
6050
6059
{
6060
+ let is_quiescent = matches!(
6061
+ self.channel_state,
6062
+ ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT)
6063
+ );
6064
+ debug_assert!(self.channel_state.is_interactive_signing() || is_quiescent);
6065
+
6051
6066
let mut commitment_number = self.counterparty_next_commitment_transaction_number;
6052
6067
let mut commitment_point = self.counterparty_next_commitment_point.unwrap();
6053
6068
@@ -6094,10 +6109,6 @@ where
6094
6109
SP::Target: SignerProvider,
6095
6110
L::Target: Logger,
6096
6111
{
6097
- assert!(
6098
- matches!(self.channel_state, ChannelState::FundingNegotiated(flags) if flags.is_interactive_signing())
6099
- );
6100
-
6101
6112
let signature = self.get_initial_counterparty_commitment_signature(funding, logger);
6102
6113
if let Some(signature) = signature {
6103
6114
log_info!(
@@ -6128,6 +6139,8 @@ where
6128
6139
SP::Target: SignerProvider,
6129
6140
L::Target: Logger,
6130
6141
{
6142
+ self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
6143
+ self.channel_state.set_interactive_signing();
6131
6144
self.counterparty_next_commitment_point = Some(counterparty_next_commitment_point_override);
6132
6145
self.get_initial_counterparty_commitment_signature(funding, logger)
6133
6146
}
@@ -8508,6 +8521,10 @@ where
8508
8521
format!("Channel {} not expecting funding signatures", self.context.channel_id);
8509
8522
return Err(APIError::APIMisuseError { err });
8510
8523
}
8524
+ debug_assert_eq!(
8525
+ self.has_pending_splice_awaiting_signatures(),
8526
+ matches!(self.context.channel_state, ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT))
8527
+ );
8511
8528
8512
8529
let signing_session =
8513
8530
if let Some(signing_session) = self.interactive_tx_signing_session.as_mut() {
@@ -8558,9 +8575,25 @@ where
8558
8575
.map_err(|err| APIError::APIMisuseError { err })?;
8559
8576
8560
8577
if funding_tx_opt.is_some() {
8561
- self.funding.funding_transaction = funding_tx_opt.clone();
8562
- self.context.channel_state =
8563
- ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8578
+ debug_assert!(tx_signatures_opt.is_some());
8579
+ debug_assert!(!self.context.channel_state.is_monitor_update_in_progress());
8580
+ debug_assert!(!self.context.channel_state.is_awaiting_remote_revoke());
8581
+
8582
+ if let Some(pending_splice) = self.pending_splice.as_mut() {
8583
+ if let Some(FundingNegotiation::AwaitingSignatures(mut funding)) =
8584
+ pending_splice.funding_negotiation.take()
8585
+ {
8586
+ funding.funding_transaction = funding_tx_opt.clone();
8587
+ self.pending_funding.push(funding);
8588
+ } else {
8589
+ debug_assert!(false, "We checked we were in the right state above");
8590
+ }
8591
+ self.context.channel_state.clear_quiescent();
8592
+ } else {
8593
+ self.funding.funding_transaction = funding_tx_opt.clone();
8594
+ self.context.channel_state =
8595
+ ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8596
+ }
8564
8597
}
8565
8598
8566
8599
Ok((tx_signatures_opt, funding_tx_opt))
@@ -8573,6 +8606,10 @@ where
8573
8606
{
8574
8607
return Err(ChannelError::Ignore("Ignoring unexpected tx_signatures".to_owned()));
8575
8608
}
8609
+ debug_assert_eq!(
8610
+ self.has_pending_splice_awaiting_signatures(),
8611
+ matches!(self.context.channel_state, ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT))
8612
+ );
8576
8613
8577
8614
let signing_session = if let Some(signing_session) = self.interactive_tx_signing_session.as_mut() {
8578
8615
if signing_session.has_received_tx_signatures() {
@@ -8605,12 +8642,24 @@ where
8605
8642
.map_err(|msg| ChannelError::Warn(msg))?;
8606
8643
8607
8644
if funding_tx_opt.is_some() {
8608
- // TODO(splicing): Transition back to `ChannelReady` and not `AwaitingChannelReady`
8609
- // We will also need to use the pending `FundingScope` in the splicing case.
8610
- //
8611
- // We have a finalized funding transaction, so we can set the funding transaction.
8612
- self.funding.funding_transaction = funding_tx_opt.clone();
8613
- self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8645
+ debug_assert!(!self.context.channel_state.is_monitor_update_in_progress());
8646
+ debug_assert!(!self.context.channel_state.is_awaiting_remote_revoke());
8647
+
8648
+ if let Some(pending_splice) = self.pending_splice.as_mut() {
8649
+ if let Some(FundingNegotiation::AwaitingSignatures(mut funding)) =
8650
+ pending_splice.funding_negotiation.take()
8651
+ {
8652
+ funding.funding_transaction = funding_tx_opt.clone();
8653
+ self.pending_funding.push(funding);
8654
+ } else {
8655
+ debug_assert!(false, "We checked we were in the right state above");
8656
+ }
8657
+ self.context.channel_state.clear_quiescent();
8658
+ } else {
8659
+ self.funding.funding_transaction = funding_tx_opt.clone();
8660
+ self.context.channel_state =
8661
+ ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
8662
+ }
8614
8663
}
8615
8664
8616
8665
Ok((holder_tx_signatures_opt, funding_tx_opt))
0 commit comments