@@ -11451,26 +11451,17 @@ where
1145111451 ES::Target: EntropySource,
1145211452 L::Target: Logger,
1145311453 {
11454- let pending_splice = if let Some(ref mut pending_splice) = &mut self.pending_splice {
11455- pending_splice
11456- } else {
11457- return Err(ChannelError::Ignore(format!("Channel is not in pending splice")));
11458- };
11459-
1146011454 // TODO(splicing): Add check that we are the splice (quiescence) initiator
1146111455
11462- let funding_negotiation_context = match pending_splice.funding_negotiation.take() {
11456+ let funding_negotiation_context = match &self
11457+ .pending_splice
11458+ .as_ref()
11459+ .ok_or(ChannelError::Ignore(format!("Channel is not in pending splice")))?
11460+ .funding_negotiation
11461+ {
1146311462 Some(FundingNegotiation::AwaitingAck(context)) => context,
11464- Some(FundingNegotiation::ConstructingTransaction(funding, constructor)) => {
11465- pending_splice.funding_negotiation =
11466- Some(FundingNegotiation::ConstructingTransaction(funding, constructor));
11467- return Err(ChannelError::WarnAndDisconnect(format!(
11468- "Got unexpected splice_ack; splice negotiation already in progress"
11469- )));
11470- },
11471- Some(FundingNegotiation::AwaitingSignatures(funding)) => {
11472- pending_splice.funding_negotiation =
11473- Some(FundingNegotiation::AwaitingSignatures(funding));
11463+ Some(FundingNegotiation::ConstructingTransaction(_, _))
11464+ | Some(FundingNegotiation::AwaitingSignatures(_)) => {
1147411465 return Err(ChannelError::WarnAndDisconnect(format!(
1147511466 "Got unexpected splice_ack; splice negotiation already in progress"
1147611467 )));
@@ -11507,6 +11498,17 @@ where
1150711498 self.funding.get_value_satoshis(),
1150811499 );
1150911500
11501+ let pending_splice =
11502+ self.pending_splice.as_mut().expect("We should have returned an error earlier!");
11503+ // TODO: Good candidate for a let else statement once MSRV >= 1.65
11504+ let funding_negotiation_context = if let Some(FundingNegotiation::AwaitingAck(context)) =
11505+ pending_splice.funding_negotiation.take()
11506+ {
11507+ context
11508+ } else {
11509+ panic!("We should have returned an error earlier!");
11510+ };
11511+
1151011512 let mut interactive_tx_constructor = funding_negotiation_context
1151111513 .into_interactive_tx_constructor(
1151211514 &self.context,
@@ -11525,8 +11527,6 @@ where
1152511527
1152611528 debug_assert!(self.interactive_tx_signing_session.is_none());
1152711529
11528- let pending_splice =
11529- self.pending_splice.as_mut().expect("pending_splice should still be set");
1153011530 pending_splice.funding_negotiation = Some(FundingNegotiation::ConstructingTransaction(
1153111531 splice_funding,
1153211532 interactive_tx_constructor,
0 commit comments