@@ -25,8 +25,6 @@ use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
2525use bitcoin::secp256k1::{PublicKey,SecretKey};
2626use bitcoin::secp256k1::{Secp256k1,ecdsa::Signature};
2727use bitcoin::{secp256k1, sighash};
28- #[cfg(splicing)]
29- use bitcoin::TxIn;
3028
3129use crate::ln::types::ChannelId;
3230use crate::types::payment::{PaymentPreimage, PaymentHash};
@@ -1188,11 +1186,12 @@ impl UnfundedChannelContext {
11881186#[derive(Clone)]
11891187pub(crate) struct PendingSpliceInfoPre {
11901188 pub our_funding_contribution: i64,
1191- pub funding_feerate_perkw: u32,
1192- pub locktime: u32,
1193- /// The funding inputs we will be contributing to the splice.
1194- /// TODO(splice): will be changed to TransactionU16LenLimited
1195- pub our_funding_inputs: Vec<(TxIn, Transaction)>,
1189+ // TODO(splicing): Enable below fields
1190+ // pub funding_feerate_perkw: u32,
1191+ // pub locktime: u32,
1192+ // /// The funding inputs we will be contributing to the splice.
1193+ // /// TODO(splice): will be changed to TransactionU16LenLimited
1194+ // pub our_funding_inputs: Vec<(TxIn, Transaction)>,
11961195}
11971196
11981197#[cfg(splicing)]
@@ -3654,6 +3653,28 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
36543653 (context.holder_selected_channel_reserve_satoshis, context.counterparty_selected_channel_reserve_satoshis)
36553654 }
36563655
3656+ /// Check that a proposed channel value meets the channel reserve requirements or violates them (below reserve)
3657+ #[cfg(any(dual_funding, splicing))]
3658+ pub fn check_channel_value_meets_reserve_requirements(&self, proposed_channel_value: u64) -> Result<(), ChannelError> {
3659+ let holder_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
3660+ proposed_channel_value, self.holder_dust_limit_satoshis);
3661+ if proposed_channel_value < holder_selected_channel_reserve_satoshis {
3662+ return Err(ChannelError::Warn(format!(
3663+ "Proposed channel value below reserve mandated by holder, {} vs {}",
3664+ proposed_channel_value, holder_selected_channel_reserve_satoshis,
3665+ )));
3666+ }
3667+ let counterparty_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
3668+ proposed_channel_value, self.counterparty_dust_limit_satoshis);
3669+ if proposed_channel_value < counterparty_selected_channel_reserve_satoshis {
3670+ return Err(ChannelError::Warn(format!(
3671+ "Proposed channel value below reserve mandated by counterparty, {} vs {}",
3672+ proposed_channel_value, counterparty_selected_channel_reserve_satoshis,
3673+ )));
3674+ }
3675+ Ok(())
3676+ }
3677+
36573678 /// Get the commitment tx fee for the local's (i.e. our) next commitment transaction based on the
36583679 /// number of pending HTLCs that are on track to be in our next commitment tx.
36593680 ///
@@ -4142,10 +4163,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
41424163 pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64, signer_provider: &SP,
41434164 funding_feerate_perkw: u32, locktime: u32,
41444165 ) -> msgs::SpliceInit {
4145- if !self.is_outbound() {
4146- panic!("Tried to initiate a splice on an inbound channel!");
4147- }
4148-
41494166 // At this point we are not committed to the new channel value yet, but the funding pubkey
41504167 // depends on the channel value, so we create here a new funding pubkey with the new
41514168 // channel value.
@@ -4175,10 +4192,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
41754192 /// Get the splice_ack message that can be sent in response to splice initiation.
41764193 #[cfg(splicing)]
41774194 pub fn get_splice_ack(&mut self, our_funding_contribution_satoshis: i64) -> Result<msgs::SpliceAck, ChannelError> {
4178- if self.is_outbound() {
4179- panic!("Tried to accept a splice on an outound channel!");
4180- }
4181-
41824195 // TODO(splicing): checks
41834196
41844197 // Note: at this point keys are already updated
@@ -7915,7 +7928,7 @@ impl<SP: Deref> Channel<SP> where
79157928 #[cfg(splicing)]
79167929 pub fn splice_init<ES: Deref, L: Deref>(
79177930 &mut self, our_funding_contribution_satoshis: i64,
7918- _signer_provider: &SP, _entropy_source: &ES, _holder_node_id: PublicKey, logger : &L
7931+ _signer_provider: &SP, _entropy_source: &ES, _holder_node_id: PublicKey, _logger : &L
79197932 )
79207933 -> Result<msgs::SpliceAck, ChannelError>
79217934 where ES::Target: EntropySource, L::Target: Logger
0 commit comments