@@ -4554,7 +4554,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4554
4554
// self.channel_state = ChannelState::NegotiatingFunding(
4555
4555
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
4556
4556
// );
4557
- log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
4557
+ log_info!(logger, "Splicing process started, new channel value {}, outgoing {}, channel_id {}",
4558
4558
self.channel_value_satoshis, is_outgoing, self.channel_id);
4559
4559
}
4560
4560
@@ -9496,6 +9496,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9496
9496
our_funding_inputs: funding_inputs,
9497
9497
},
9498
9498
interactive_tx_constructor: None,
9499
+ #[cfg(splicing)]
9499
9500
pending_splice_post: None,
9500
9501
};
9501
9502
Ok(chan)
@@ -9505,7 +9506,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9505
9506
#[cfg(splicing)]
9506
9507
pub fn new_spliced<L: Deref>(
9507
9508
is_outbound: bool,
9508
- pre_splice_channel: &mut Channel<SP>,
9509
+ pre_splice_channel: &Channel<SP>,
9509
9510
signer_provider: &SP,
9510
9511
counterparty_funding_pubkey: &PublicKey,
9511
9512
our_funding_contribution: i64,
@@ -9558,7 +9559,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9558
9559
their_funding_satoshis: Some(their_funding_satoshis),
9559
9560
funding_tx_locktime,
9560
9561
funding_feerate_sat_per_1000_weight,
9561
- our_funding_inputs: Some( funding_inputs) ,
9562
+ our_funding_inputs: funding_inputs,
9562
9563
};
9563
9564
let unfunded_context = UnfundedChannelContext::default();
9564
9565
let post_chan = Self {
@@ -9655,6 +9656,9 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
9655
9656
pub dual_funding_context: DualFundingChannelContext,
9656
9657
/// The current interactive transaction construction session under negotiation.
9657
9658
interactive_tx_constructor: Option<InteractiveTxConstructor>,
9659
+ /// Info about an in-progress, pending splice (if any), on the post-splice channel
9660
+ #[cfg(splicing)]
9661
+ pending_splice_post: Option<PendingSplicePost>,
9658
9662
}
9659
9663
9660
9664
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
@@ -9758,9 +9762,81 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9758
9762
dual_funding_context,
9759
9763
interactive_tx_constructor,
9760
9764
unfunded_context: UnfundedChannelContext::default(),
9765
+ #[cfg(splicing)]
9766
+ pending_splice_post: None,
9761
9767
})
9762
9768
}
9763
9769
9770
+ /// Create new channel for splicing
9771
+ #[cfg(splicing)]
9772
+ pub fn new_spliced<L: Deref>(
9773
+ is_outbound: bool,
9774
+ pre_splice_channel: &Channel<SP>,
9775
+ signer_provider: &SP,
9776
+ counterparty_funding_pubkey: &PublicKey,
9777
+ our_funding_contribution: i64,
9778
+ their_funding_contribution: i64,
9779
+ funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
9780
+ funding_tx_locktime: LockTime,
9781
+ funding_feerate_sat_per_1000_weight: u32,
9782
+ logger: &L,
9783
+ ) -> Result<Self, ChannelError> where L::Target: Logger
9784
+ {
9785
+ if pre_splice_channel.is_splice_pending() {
9786
+ return Err(ChannelError::Warn(format!("Internal error: Channel is already splicing, channel_id {}", pre_splice_channel.context.channel_id)));
9787
+ }
9788
+
9789
+ let pre_channel_value = pre_splice_channel.context.get_value_satoshis();
9790
+
9791
+ // Save the current funding transaction
9792
+ let pre_funding_transaction = pre_splice_channel.context.funding_transaction.clone();
9793
+ let pre_funding_txo = pre_splice_channel.context.get_funding_txo().clone();
9794
+
9795
+ let pending_splice_post = PendingSplicePost::new(
9796
+ pre_channel_value, our_funding_contribution, their_funding_contribution,
9797
+ pre_funding_transaction, pre_funding_txo,
9798
+ );
9799
+ let post_channel_value = pending_splice_post.post_channel_value();
9800
+
9801
+ // Create new signer, using the new channel value.
9802
+ // Note: channel_keys_id is not changed
9803
+ let holder_signer = signer_provider.derive_channel_signer(post_channel_value, pre_splice_channel.context.channel_keys_id);
9804
+
9805
+ let context = ChannelContext::new_for_splice(
9806
+ &pre_splice_channel.context,
9807
+ false,
9808
+ counterparty_funding_pubkey,
9809
+ our_funding_contribution,
9810
+ their_funding_contribution,
9811
+ holder_signer,
9812
+ logger,
9813
+ )?;
9814
+
9815
+ let (our_funding_satoshis, their_funding_satoshis) = calculate_funding_values(
9816
+ pre_channel_value,
9817
+ our_funding_contribution,
9818
+ their_funding_contribution,
9819
+ is_outbound,
9820
+ )?;
9821
+
9822
+ let dual_funding_context = DualFundingChannelContext {
9823
+ our_funding_satoshis,
9824
+ their_funding_satoshis: Some(their_funding_satoshis),
9825
+ funding_tx_locktime,
9826
+ funding_feerate_sat_per_1000_weight,
9827
+ our_funding_inputs: funding_inputs,
9828
+ };
9829
+ let unfunded_context = UnfundedChannelContext::default();
9830
+ let post_chan = Self {
9831
+ context,
9832
+ dual_funding_context,
9833
+ unfunded_context,
9834
+ interactive_tx_constructor: None,
9835
+ pending_splice_post: Some(pending_splice_post),
9836
+ };
9837
+ Ok(post_chan)
9838
+ }
9839
+
9764
9840
/// Marks an inbound channel as accepted and generates a [`msgs::AcceptChannelV2`] message which
9765
9841
/// should be sent back to the counterparty node.
9766
9842
///
@@ -9840,7 +9916,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9840
9916
#[cfg(splicing)]
9841
9917
pending_splice_pre: None,
9842
9918
#[cfg(splicing)]
9843
- pending_splice_post: None ,
9919
+ pending_splice_post: self.pending_splice_post ,
9844
9920
};
9845
9921
9846
9922
Ok(channel)
0 commit comments