@@ -4503,7 +4503,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4503
4503
// self.channel_state = ChannelState::NegotiatingFunding(
4504
4504
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
4505
4505
// );
4506
- log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
4506
+ log_info!(logger, "Splicing process started, new channel value {}, outgoing {}, channel_id {}",
4507
4507
self.channel_value_satoshis, is_outgoing, self.channel_id);
4508
4508
}
4509
4509
@@ -8913,7 +8913,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8913
8913
pubkeys,
8914
8914
logger,
8915
8915
)?,
8916
- unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
8916
+ unfunded_context: UnfundedChannelContext::default(),
8917
8917
};
8918
8918
Ok(chan)
8919
8919
}
@@ -9221,7 +9221,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
9221
9221
msg.push_msat,
9222
9222
msg.common_fields.clone(),
9223
9223
)?,
9224
- unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 } ,
9224
+ unfunded_context: UnfundedChannelContext::default() ,
9225
9225
};
9226
9226
Ok(chan)
9227
9227
}
@@ -9434,7 +9434,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9434
9434
pubkeys,
9435
9435
logger,
9436
9436
)?,
9437
- unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 } ,
9437
+ unfunded_context: UnfundedChannelContext::default() ,
9438
9438
dual_funding_context: DualFundingChannelContext {
9439
9439
our_funding_satoshis: funding_satoshis,
9440
9440
their_funding_satoshis: None,
@@ -9443,6 +9443,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9443
9443
our_funding_inputs: Some(funding_inputs),
9444
9444
},
9445
9445
interactive_tx_constructor: None,
9446
+ #[cfg(splicing)]
9446
9447
pending_splice_post: None,
9447
9448
};
9448
9449
Ok(chan)
@@ -9452,7 +9453,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
9452
9453
#[cfg(splicing)]
9453
9454
pub fn new_spliced<L: Deref>(
9454
9455
is_outbound: bool,
9455
- pre_splice_channel: &mut Channel<SP>,
9456
+ pre_splice_channel: &Channel<SP>,
9456
9457
signer_provider: &SP,
9457
9458
counterparty_funding_pubkey: &PublicKey,
9458
9459
our_funding_contribution: i64,
@@ -9602,6 +9603,9 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
9602
9603
pub dual_funding_context: DualFundingChannelContext,
9603
9604
/// The current interactive transaction construction session under negotiation.
9604
9605
interactive_tx_constructor: Option<InteractiveTxConstructor>,
9606
+ /// Info about an in-progress, pending splice (if any), on the post-splice channel
9607
+ #[cfg(splicing)]
9608
+ pending_splice_post: Option<PendingSplicePost>,
9605
9609
}
9606
9610
9607
9611
impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
@@ -9704,10 +9708,82 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9704
9708
context,
9705
9709
dual_funding_context,
9706
9710
interactive_tx_constructor,
9707
- unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 },
9711
+ unfunded_context: UnfundedChannelContext::default(),
9712
+ #[cfg(splicing)]
9713
+ pending_splice_post: None,
9708
9714
})
9709
9715
}
9710
9716
9717
+ /// Create new channel for splicing
9718
+ #[cfg(splicing)]
9719
+ pub fn new_spliced<L: Deref>(
9720
+ is_outbound: bool,
9721
+ pre_splice_channel: &Channel<SP>,
9722
+ signer_provider: &SP,
9723
+ counterparty_funding_pubkey: &PublicKey,
9724
+ our_funding_contribution: i64,
9725
+ their_funding_contribution: i64,
9726
+ funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
9727
+ funding_tx_locktime: LockTime,
9728
+ funding_feerate_sat_per_1000_weight: u32,
9729
+ logger: &L,
9730
+ ) -> Result<Self, ChannelError> where L::Target: Logger
9731
+ {
9732
+ if pre_splice_channel.is_splice_pending() {
9733
+ return Err(ChannelError::Warn(format!("Internal error: Channel is already splicing, channel_id {}", pre_splice_channel.context.channel_id)));
9734
+ }
9735
+
9736
+ let pre_channel_value = pre_splice_channel.context.get_value_satoshis();
9737
+
9738
+ // Save the current funding transaction
9739
+ let pre_funding_transaction = pre_splice_channel.context.funding_transaction.clone();
9740
+ let pre_funding_txo = pre_splice_channel.context.get_funding_txo().clone();
9741
+
9742
+ let pending_splice_post = PendingSplicePost::new(
9743
+ pre_channel_value, our_funding_contribution, their_funding_contribution,
9744
+ pre_funding_transaction, pre_funding_txo,
9745
+ );
9746
+ let post_channel_value = pending_splice_post.post_channel_value();
9747
+
9748
+ // Create new signer, using the new channel value.
9749
+ // Note: channel_keys_id is not changed
9750
+ let holder_signer = signer_provider.derive_channel_signer(post_channel_value, pre_splice_channel.context.channel_keys_id);
9751
+
9752
+ let context = ChannelContext::new_for_splice(
9753
+ &pre_splice_channel.context,
9754
+ false,
9755
+ counterparty_funding_pubkey,
9756
+ our_funding_contribution,
9757
+ their_funding_contribution,
9758
+ holder_signer,
9759
+ logger,
9760
+ )?;
9761
+
9762
+ let (our_funding_satoshis, their_funding_satoshis) = calculate_funding_values(
9763
+ pre_channel_value,
9764
+ our_funding_contribution,
9765
+ their_funding_contribution,
9766
+ is_outbound,
9767
+ )?;
9768
+
9769
+ let dual_funding_context = DualFundingChannelContext {
9770
+ our_funding_satoshis,
9771
+ their_funding_satoshis: Some(their_funding_satoshis),
9772
+ funding_tx_locktime,
9773
+ funding_feerate_sat_per_1000_weight,
9774
+ our_funding_inputs: Some(funding_inputs),
9775
+ };
9776
+ let unfunded_context = UnfundedChannelContext::default();
9777
+ let post_chan = Self {
9778
+ context,
9779
+ dual_funding_context,
9780
+ unfunded_context,
9781
+ interactive_tx_constructor: None,
9782
+ pending_splice_post: Some(pending_splice_post),
9783
+ };
9784
+ Ok(post_chan)
9785
+ }
9786
+
9711
9787
/// Marks an inbound channel as accepted and generates a [`msgs::AcceptChannelV2`] message which
9712
9788
/// should be sent back to the counterparty node.
9713
9789
///
@@ -9787,7 +9863,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
9787
9863
#[cfg(splicing)]
9788
9864
pending_splice_pre: None,
9789
9865
#[cfg(splicing)]
9790
- pending_splice_post: None ,
9866
+ pending_splice_post: self.pending_splice_post ,
9791
9867
};
9792
9868
9793
9869
Ok(channel)
0 commit comments