@@ -10821,7 +10821,7 @@ where
10821
10821
})
10822
10822
}
10823
10823
10824
- /// Handle splice_ack
10824
+ /// See also [`validate_splice_ack`]
10825
10825
#[cfg(splicing)]
10826
10826
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
10827
10827
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
@@ -10831,42 +10831,7 @@ where
10831
10831
ES::Target: EntropySource,
10832
10832
L::Target: Logger,
10833
10833
{
10834
- // TODO(splicing): Add check that we are the splice (quiescence) initiator
10835
-
10836
- let funding_negotiation_context = match &self
10837
- .pending_splice
10838
- .as_ref()
10839
- .ok_or(ChannelError::Ignore(format!("Channel is not in pending splice")))?
10840
- .funding_negotiation
10841
- {
10842
- Some(FundingNegotiation::AwaitingAck(context)) => context,
10843
- Some(FundingNegotiation::ConstructingTransaction(_, _))
10844
- | Some(FundingNegotiation::AwaitingSignatures(_)) => {
10845
- return Err(ChannelError::WarnAndDisconnect(format!(
10846
- "Got unexpected splice_ack; splice negotiation already in progress"
10847
- )));
10848
- },
10849
- None => {
10850
- return Err(ChannelError::Ignore(format!(
10851
- "Got unexpected splice_ack; no splice negotiation in progress"
10852
- )));
10853
- },
10854
- };
10855
-
10856
- let our_funding_contribution_satoshis =
10857
- funding_negotiation_context.our_funding_contribution_satoshis;
10858
- let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
10859
-
10860
- let splice_funding = FundingScope::for_splice(
10861
- &self.funding,
10862
- &self.context,
10863
- our_funding_contribution_satoshis,
10864
- their_funding_contribution_satoshis,
10865
- msg.funding_pubkey,
10866
- )?;
10867
-
10868
- // TODO(splicing): Pre-check for reserve requirement
10869
- // (Note: It should also be checked later at tx_complete)
10834
+ let splice_funding = self.validate_splice_ack(msg)?;
10870
10835
10871
10836
log_info!(
10872
10837
logger,
@@ -10912,6 +10877,49 @@ where
10912
10877
Ok(tx_msg_opt)
10913
10878
}
10914
10879
10880
+ /// Checks during handling splice_ack
10881
+ #[cfg(splicing)]
10882
+ fn validate_splice_ack(&self, msg: &msgs::SpliceAck) -> Result<FundingScope, ChannelError> {
10883
+ // TODO(splicing): Add check that we are the splice (quiescence) initiator
10884
+
10885
+ let funding_negotiation_context = match &self
10886
+ .pending_splice
10887
+ .as_ref()
10888
+ .ok_or(ChannelError::Ignore(format!("Channel is not in pending splice")))?
10889
+ .funding_negotiation
10890
+ {
10891
+ Some(FundingNegotiation::AwaitingAck(context)) => context,
10892
+ Some(FundingNegotiation::ConstructingTransaction(_, _))
10893
+ | Some(FundingNegotiation::AwaitingSignatures(_)) => {
10894
+ return Err(ChannelError::WarnAndDisconnect(format!(
10895
+ "Got unexpected splice_ack; splice negotiation already in progress"
10896
+ )));
10897
+ },
10898
+ None => {
10899
+ return Err(ChannelError::Ignore(format!(
10900
+ "Got unexpected splice_ack; no splice negotiation in progress"
10901
+ )));
10902
+ },
10903
+ };
10904
+
10905
+ let our_funding_contribution_satoshis =
10906
+ funding_negotiation_context.our_funding_contribution_satoshis;
10907
+ let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
10908
+
10909
+ let splice_funding = FundingScope::for_splice(
10910
+ &self.funding,
10911
+ &self.context,
10912
+ our_funding_contribution_satoshis,
10913
+ their_funding_contribution_satoshis,
10914
+ msg.funding_pubkey,
10915
+ )?;
10916
+
10917
+ // TODO(splicing): Pre-check for reserve requirement
10918
+ // (Note: It should also be checked later at tx_complete)
10919
+
10920
+ Ok(splice_funding)
10921
+ }
10922
+
10915
10923
#[cfg(splicing)]
10916
10924
pub fn splice_locked<NS: Deref, L: Deref>(
10917
10925
&mut self, msg: &msgs::SpliceLocked, node_signer: &NS, chain_hash: ChainHash,
0 commit comments