@@ -10847,6 +10847,33 @@ where
10847
10847
}
10848
10848
10849
10849
let their_funding_contribution = SignedAmount::from_sat(msg.funding_contribution_satoshis);
10850
+ self.validate_splice_contribution(their_funding_contribution)?;
10851
+
10852
+ // TODO(splicing): Check that channel balance does not go below the channel reserve
10853
+
10854
+ let splice_funding = FundingScope::for_splice(
10855
+ &self.funding,
10856
+ &self.context,
10857
+ our_funding_contribution,
10858
+ their_funding_contribution,
10859
+ msg.funding_pubkey,
10860
+ )?;
10861
+
10862
+ // TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
10863
+ // similarly to the check in `splice_channel`.
10864
+
10865
+ // Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
10866
+ // it can't go below reserve, therefore no pre-check is done here.
10867
+
10868
+ // TODO(splicing): Early check for reserve requirement
10869
+
10870
+ Ok(splice_funding)
10871
+ }
10872
+
10873
+ #[cfg(splicing)]
10874
+ fn validate_splice_contribution(
10875
+ &self, their_funding_contribution: SignedAmount,
10876
+ ) -> Result<(), ChannelError> {
10850
10877
if their_funding_contribution > SignedAmount::MAX_MONEY {
10851
10878
return Err(ChannelError::WarnAndDisconnect(format!(
10852
10879
"Channel {} cannot be spliced in; their {} contribution exceeds the total bitcoin supply",
@@ -10879,25 +10906,7 @@ where
10879
10906
)));
10880
10907
}
10881
10908
10882
- // TODO(splicing): Check that channel balance does not go below the channel reserve
10883
-
10884
- let splice_funding = FundingScope::for_splice(
10885
- &self.funding,
10886
- &self.context,
10887
- our_funding_contribution,
10888
- their_funding_contribution,
10889
- msg.funding_pubkey,
10890
- )?;
10891
-
10892
- // TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
10893
- // similarly to the check in `splice_channel`.
10894
-
10895
- // Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
10896
- // it can't go below reserve, therefore no pre-check is done here.
10897
-
10898
- // TODO(splicing): Early check for reserve requirement
10899
-
10900
- Ok(splice_funding)
10909
+ Ok(())
10901
10910
}
10902
10911
10903
10912
/// See also [`validate_splice_init`]
@@ -11013,37 +11022,7 @@ where
11013
11022
debug_assert!(our_funding_contribution <= SignedAmount::MAX_MONEY);
11014
11023
11015
11024
let their_funding_contribution = SignedAmount::from_sat(msg.funding_contribution_satoshis);
11016
- if their_funding_contribution > SignedAmount::MAX_MONEY {
11017
- return Err(ChannelError::WarnAndDisconnect(format!(
11018
- "Channel {} cannot be spliced in; their {} contribution exceeds the total bitcoin supply",
11019
- self.context.channel_id(),
11020
- their_funding_contribution,
11021
- )));
11022
- }
11023
-
11024
- if their_funding_contribution < -SignedAmount::MAX_MONEY {
11025
- return Err(ChannelError::WarnAndDisconnect(format!(
11026
- "Channel {} cannot be spliced out; their {} contribution exhausts the total bitcoin supply",
11027
- self.context.channel_id(),
11028
- their_funding_contribution,
11029
- )));
11030
- }
11031
-
11032
- let their_channel_balance = Amount::from_sat(self.funding.get_value_satoshis())
11033
- - Amount::from_sat(self.funding.get_value_to_self_msat() / 1000);
11034
- let post_channel_balance = AddSigned::checked_add_signed(
11035
- their_channel_balance.to_sat(),
11036
- their_funding_contribution.to_sat(),
11037
- );
11038
-
11039
- if post_channel_balance.is_none() {
11040
- return Err(ChannelError::WarnAndDisconnect(format!(
11041
- "Channel {} cannot be spliced out; their {} contribution exhausts their channel balance: {}",
11042
- self.context.channel_id(),
11043
- their_funding_contribution,
11044
- their_channel_balance,
11045
- )));
11046
- }
11025
+ self.validate_splice_contribution(their_funding_contribution)?;
11047
11026
11048
11027
let splice_funding = FundingScope::for_splice(
11049
11028
&self.funding,
@@ -11081,6 +11060,9 @@ where
11081
11060
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
11082
11061
11083
11062
debug_assert!(self.interactive_tx_signing_session.is_none());
11063
+
11064
+ let pending_splice =
11065
+ self.pending_splice.as_mut().expect("pending_splice should still be set");
11084
11066
pending_splice.funding_negotiation = Some(FundingNegotiation::ConstructingTransaction(
11085
11067
splice_funding,
11086
11068
interactive_tx_constructor,
0 commit comments