@@ -25,8 +25,6 @@ use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
25
25
use bitcoin::secp256k1::{PublicKey,SecretKey};
26
26
use bitcoin::secp256k1::{Secp256k1,ecdsa::Signature};
27
27
use bitcoin::{secp256k1, sighash};
28
- #[cfg(splicing)]
29
- use bitcoin::TxIn;
30
28
31
29
use crate::ln::types::ChannelId;
32
30
use crate::types::payment::{PaymentPreimage, PaymentHash};
@@ -1188,11 +1186,12 @@ impl UnfundedChannelContext {
1188
1186
#[derive(Clone)]
1189
1187
pub(crate) struct PendingSpliceInfoPre {
1190
1188
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)>,
1196
1195
}
1197
1196
1198
1197
#[cfg(splicing)]
@@ -3654,6 +3653,28 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3654
3653
(context.holder_selected_channel_reserve_satoshis, context.counterparty_selected_channel_reserve_satoshis)
3655
3654
}
3656
3655
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
+
3657
3678
/// Get the commitment tx fee for the local's (i.e. our) next commitment transaction based on the
3658
3679
/// number of pending HTLCs that are on track to be in our next commitment tx.
3659
3680
///
@@ -4142,10 +4163,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4142
4163
pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64, signer_provider: &SP,
4143
4164
funding_feerate_perkw: u32, locktime: u32,
4144
4165
) -> msgs::SpliceInit {
4145
- if !self.is_outbound() {
4146
- panic!("Tried to initiate a splice on an inbound channel!");
4147
- }
4148
-
4149
4166
// At this point we are not committed to the new channel value yet, but the funding pubkey
4150
4167
// depends on the channel value, so we create here a new funding pubkey with the new
4151
4168
// channel value.
@@ -4175,10 +4192,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4175
4192
/// Get the splice_ack message that can be sent in response to splice initiation.
4176
4193
#[cfg(splicing)]
4177
4194
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
-
4182
4195
// TODO(splicing): checks
4183
4196
4184
4197
// Note: at this point keys are already updated
@@ -7915,7 +7928,7 @@ impl<SP: Deref> Channel<SP> where
7915
7928
#[cfg(splicing)]
7916
7929
pub fn splice_init<ES: Deref, L: Deref>(
7917
7930
&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
7919
7932
)
7920
7933
-> Result<msgs::SpliceAck, ChannelError>
7921
7934
where ES::Target: EntropySource, L::Target: Logger
0 commit comments