@@ -4388,7 +4388,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4388
4388
latest_monitor_update_id: self.latest_monitor_update_id,
4389
4389
shutdown_scriptpubkey: self.shutdown_scriptpubkey.clone(),
4390
4390
destination_script: self.destination_script.clone(),
4391
- holder_commitment_point: self.holder_commitment_point,
4392
4391
cur_counterparty_commitment_transaction_number: self.cur_counterparty_commitment_transaction_number,
4393
4392
value_to_self_msat: self.value_to_self_msat,
4394
4393
pending_inbound_htlcs: self.pending_inbound_htlcs.clone(),
@@ -4407,6 +4406,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4407
4406
signer_pending_commitment_update: self.signer_pending_commitment_update,
4408
4407
signer_pending_funding: self.signer_pending_funding,
4409
4408
signer_pending_closing: self.signer_pending_closing,
4409
+ signer_pending_channel_ready: self.signer_pending_channel_ready,
4410
4410
pending_update_fee: self.pending_update_fee,
4411
4411
holding_cell_update_fee: self.holding_cell_update_fee,
4412
4412
next_holder_htlc_id: self.next_holder_htlc_id,
@@ -4557,7 +4557,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4557
4557
// self.channel_state = ChannelState::NegotiatingFunding(
4558
4558
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
4559
4559
// );
4560
- log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
4560
+ log_info!(logger, "Splicing process started, new channel value {}, outgoing {}, channel_id {}",
4561
4561
self.channel_value_satoshis, is_outgoing, self.channel_id);
4562
4562
}
4563
4563
@@ -9594,6 +9594,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9594
9594
our_funding_inputs: funding_inputs,
9595
9595
},
9596
9596
interactive_tx_constructor: None,
9597
+ #[cfg(splicing)]
9597
9598
pending_splice_post: None,
9598
9599
};
9599
9600
Ok(chan)
@@ -9603,7 +9604,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9603
9604
#[cfg(splicing)]
9604
9605
pub fn new_spliced<L: Deref>(
9605
9606
is_outbound: bool,
9606
- pre_splice_channel: &mut Channel<SP>,
9607
+ pre_splice_channel: &Channel<SP>,
9607
9608
signer_provider: &SP,
9608
9609
counterparty_funding_pubkey: &PublicKey,
9609
9610
our_funding_contribution: i64,
@@ -9656,9 +9657,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9656
9657
their_funding_satoshis: Some(their_funding_satoshis),
9657
9658
funding_tx_locktime,
9658
9659
funding_feerate_sat_per_1000_weight,
9659
- our_funding_inputs: Some(funding_inputs),
9660
+ our_funding_inputs: funding_inputs,
9661
+ };
9662
+ let unfunded_context = UnfundedChannelContext {
9663
+ unfunded_channel_age_ticks: 0,
9664
+ holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
9660
9665
};
9661
- let unfunded_context = UnfundedChannelContext::default();
9662
9666
let post_chan = Self {
9663
9667
context,
9664
9668
dual_funding_context,
@@ -9757,6 +9761,9 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
9757
9761
pub dual_funding_context: DualFundingChannelContext,
9758
9762
/// The current interactive transaction construction session under negotiation.
9759
9763
interactive_tx_constructor: Option<InteractiveTxConstructor>,
9764
+ /// Info about an in-progress, pending splice (if any), on the post-splice channel
9765
+ #[cfg(splicing)]
9766
+ pending_splice_post: Option<PendingSplicePost>,
9760
9767
}
9761
9768
9762
9769
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
@@ -9865,9 +9872,84 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9865
9872
dual_funding_context,
9866
9873
interactive_tx_constructor,
9867
9874
unfunded_context,
9875
+ #[cfg(splicing)]
9876
+ pending_splice_post: None,
9868
9877
})
9869
9878
}
9870
9879
9880
+ /// Create new channel for splicing
9881
+ #[cfg(splicing)]
9882
+ pub fn new_spliced<L: Deref>(
9883
+ is_outbound: bool,
9884
+ pre_splice_channel: &Channel<SP>,
9885
+ signer_provider: &SP,
9886
+ counterparty_funding_pubkey: &PublicKey,
9887
+ our_funding_contribution: i64,
9888
+ their_funding_contribution: i64,
9889
+ funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
9890
+ funding_tx_locktime: LockTime,
9891
+ funding_feerate_sat_per_1000_weight: u32,
9892
+ logger: &L,
9893
+ ) -> Result<Self, ChannelError> where L::Target: Logger
9894
+ {
9895
+ if pre_splice_channel.is_splice_pending() {
9896
+ return Err(ChannelError::Warn(format!("Internal error: Channel is already splicing, channel_id {}", pre_splice_channel.context.channel_id)));
9897
+ }
9898
+
9899
+ let pre_channel_value = pre_splice_channel.context.get_value_satoshis();
9900
+
9901
+ // Save the current funding transaction
9902
+ let pre_funding_transaction = pre_splice_channel.context.funding_transaction.clone();
9903
+ let pre_funding_txo = pre_splice_channel.context.get_funding_txo().clone();
9904
+
9905
+ let pending_splice_post = PendingSplicePost::new(
9906
+ pre_channel_value, our_funding_contribution, their_funding_contribution,
9907
+ pre_funding_transaction, pre_funding_txo,
9908
+ );
9909
+ let post_channel_value = pending_splice_post.post_channel_value();
9910
+
9911
+ // Create new signer, using the new channel value.
9912
+ // Note: channel_keys_id is not changed
9913
+ let holder_signer = signer_provider.derive_channel_signer(post_channel_value, pre_splice_channel.context.channel_keys_id);
9914
+
9915
+ let context = ChannelContext::new_for_splice(
9916
+ &pre_splice_channel.context,
9917
+ false,
9918
+ counterparty_funding_pubkey,
9919
+ our_funding_contribution,
9920
+ their_funding_contribution,
9921
+ holder_signer,
9922
+ logger,
9923
+ )?;
9924
+
9925
+ let (our_funding_satoshis, their_funding_satoshis) = calculate_funding_values(
9926
+ pre_channel_value,
9927
+ our_funding_contribution,
9928
+ their_funding_contribution,
9929
+ is_outbound,
9930
+ )?;
9931
+
9932
+ let dual_funding_context = DualFundingChannelContext {
9933
+ our_funding_satoshis,
9934
+ their_funding_satoshis: Some(their_funding_satoshis),
9935
+ funding_tx_locktime,
9936
+ funding_feerate_sat_per_1000_weight,
9937
+ our_funding_inputs: funding_inputs,
9938
+ };
9939
+ let unfunded_context = UnfundedChannelContext {
9940
+ unfunded_channel_age_ticks: 0,
9941
+ holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
9942
+ };
9943
+ let post_chan = Self {
9944
+ context,
9945
+ dual_funding_context,
9946
+ unfunded_context,
9947
+ interactive_tx_constructor: None,
9948
+ pending_splice_post: Some(pending_splice_post),
9949
+ };
9950
+ Ok(post_chan)
9951
+ }
9952
+
9871
9953
/// Marks an inbound channel as accepted and generates a [`msgs::AcceptChannelV2`] message which
9872
9954
/// should be sent back to the counterparty node.
9873
9955
///
@@ -9953,7 +10035,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9953
10035
#[cfg(splicing)]
9954
10036
pending_splice_pre: None,
9955
10037
#[cfg(splicing)]
9956
- pending_splice_post: None ,
10038
+ pending_splice_post: self.pending_splice_post ,
9957
10039
};
9958
10040
9959
10041
Ok(channel)
0 commit comments