@@ -23,8 +23,6 @@ use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
23
23
use bitcoin::secp256k1::{PublicKey,SecretKey};
24
24
use bitcoin::secp256k1::{Secp256k1,ecdsa::Signature};
25
25
use bitcoin::{secp256k1, sighash};
26
- #[cfg(splicing)]
27
- use bitcoin::TxIn;
28
26
29
27
use crate::ln::types::ChannelId;
30
28
use crate::types::payment::{PaymentPreimage, PaymentHash};
@@ -1185,11 +1183,12 @@ impl UnfundedChannelContext {
1185
1183
#[derive(Clone)]
1186
1184
pub(crate) struct PendingSpliceInfoPre {
1187
1185
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)>,
1193
1192
}
1194
1193
1195
1194
#[cfg(splicing)]
@@ -3425,6 +3424,28 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3425
3424
(context.holder_selected_channel_reserve_satoshis, context.counterparty_selected_channel_reserve_satoshis)
3426
3425
}
3427
3426
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
+
3428
3449
/// Get the commitment tx fee for the local's (i.e. our) next commitment transaction based on the
3429
3450
/// number of pending HTLCs that are on track to be in our next commitment tx.
3430
3451
///
@@ -3828,10 +3849,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3828
3849
pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64, signer_provider: &SP,
3829
3850
funding_feerate_perkw: u32, locktime: u32,
3830
3851
) -> msgs::SpliceInit {
3831
- if !self.is_outbound() {
3832
- panic!("Tried to initiate a splice on an inbound channel!");
3833
- }
3834
-
3835
3852
// At this point we are not committed to the new channel value yet, but the funding pubkey
3836
3853
// depends on the channel value, so we create here a new funding pubkey with the new
3837
3854
// channel value.
@@ -3861,10 +3878,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3861
3878
/// Get the splice_ack message that can be sent in response to splice initiation.
3862
3879
#[cfg(splicing)]
3863
3880
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
-
3868
3881
// TODO(splicing): checks
3869
3882
3870
3883
// Note: at this point keys are already updated
@@ -7458,7 +7471,7 @@ impl<SP: Deref> Channel<SP> where
7458
7471
#[cfg(splicing)]
7459
7472
pub fn splice_init<ES: Deref, L: Deref>(
7460
7473
&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
7462
7475
)
7463
7476
-> Result<msgs::SpliceAck, ChannelError>
7464
7477
where ES::Target: EntropySource, L::Target: Logger
0 commit comments