@@ -23,8 +23,6 @@ use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
2323use bitcoin::secp256k1::{PublicKey,SecretKey};
2424use bitcoin::secp256k1::{Secp256k1,ecdsa::Signature};
2525use bitcoin::{secp256k1, sighash};
26- #[cfg(splicing)]
27- use bitcoin::TxIn;
2826
2927use crate::ln::types::ChannelId;
3028use crate::types::payment::{PaymentPreimage, PaymentHash};
@@ -1185,11 +1183,12 @@ impl UnfundedChannelContext {
11851183#[derive(Clone)]
11861184pub(crate) struct PendingSpliceInfoPre {
11871185 pub our_funding_contribution: i64,
1188- pub funding_feerate_perkw: u32,
1189- pub locktime: u32,
1190- /// The funding inputs we will be contributing to the splice.
1191- /// TODO(splice): will be changed to TransactionU16LenLimited
1192- pub our_funding_inputs: Vec<(TxIn, Transaction)>,
1186+ // TODO(splicing): Enable below fields
1187+ // pub funding_feerate_perkw: u32,
1188+ // pub locktime: u32,
1189+ // /// The funding inputs we will be contributing to the splice.
1190+ // /// TODO(splice): will be changed to TransactionU16LenLimited
1191+ // pub our_funding_inputs: Vec<(TxIn, Transaction)>,
11931192}
11941193
11951194#[cfg(splicing)]
@@ -3425,6 +3424,28 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34253424 (context.holder_selected_channel_reserve_satoshis, context.counterparty_selected_channel_reserve_satoshis)
34263425 }
34273426
3427+ /// Check that a proposed channel value meets the channel reserve requirements or violates them (below reserve)
3428+ #[cfg(any(dual_funding, splicing))]
3429+ pub fn check_channel_value_meets_reserve_requirements(&self, proposed_channel_value: u64) -> Result<(), ChannelError> {
3430+ let holder_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
3431+ proposed_channel_value, self.holder_dust_limit_satoshis);
3432+ if proposed_channel_value < holder_selected_channel_reserve_satoshis {
3433+ return Err(ChannelError::Warn(format!(
3434+ "Proposed channel value below reserve mandated by holder, {} vs {}",
3435+ proposed_channel_value, holder_selected_channel_reserve_satoshis,
3436+ )));
3437+ }
3438+ let counterparty_selected_channel_reserve_satoshis = get_v2_channel_reserve_satoshis(
3439+ proposed_channel_value, self.counterparty_dust_limit_satoshis);
3440+ if proposed_channel_value < counterparty_selected_channel_reserve_satoshis {
3441+ return Err(ChannelError::Warn(format!(
3442+ "Proposed channel value below reserve mandated by counterparty, {} vs {}",
3443+ proposed_channel_value, counterparty_selected_channel_reserve_satoshis,
3444+ )));
3445+ }
3446+ Ok(())
3447+ }
3448+
34283449 /// Get the commitment tx fee for the local's (i.e. our) next commitment transaction based on the
34293450 /// number of pending HTLCs that are on track to be in our next commitment tx.
34303451 ///
@@ -3828,10 +3849,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38283849 pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64, signer_provider: &SP,
38293850 funding_feerate_perkw: u32, locktime: u32,
38303851 ) -> msgs::SpliceInit {
3831- if !self.is_outbound() {
3832- panic!("Tried to initiate a splice on an inbound channel!");
3833- }
3834-
38353852 // At this point we are not committed to the new channel value yet, but the funding pubkey
38363853 // depends on the channel value, so we create here a new funding pubkey with the new
38373854 // channel value.
@@ -3861,10 +3878,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38613878 /// Get the splice_ack message that can be sent in response to splice initiation.
38623879 #[cfg(splicing)]
38633880 pub fn get_splice_ack(&mut self, our_funding_contribution_satoshis: i64) -> Result<msgs::SpliceAck, ChannelError> {
3864- if self.is_outbound() {
3865- panic!("Tried to accept a splice on an outound channel!");
3866- }
3867-
38683881 // TODO(splicing): checks
38693882
38703883 // Note: at this point keys are already updated
@@ -7458,7 +7471,7 @@ impl<SP: Deref> Channel<SP> where
74587471 #[cfg(splicing)]
74597472 pub fn splice_init<ES: Deref, L: Deref>(
74607473 &mut self, our_funding_contribution_satoshis: i64,
7461- _signer_provider: &SP, _entropy_source: &ES, _holder_node_id: PublicKey, logger : &L
7474+ _signer_provider: &SP, _entropy_source: &ES, _holder_node_id: PublicKey, _logger : &L
74627475 )
74637476 -> Result<msgs::SpliceAck, ChannelError>
74647477 where ES::Target: EntropySource, L::Target: Logger
0 commit comments