@@ -4388,7 +4388,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
43884388 latest_monitor_update_id: self.latest_monitor_update_id,
43894389 shutdown_scriptpubkey: self.shutdown_scriptpubkey.clone(),
43904390 destination_script: self.destination_script.clone(),
4391- holder_commitment_point: self.holder_commitment_point,
43924391 cur_counterparty_commitment_transaction_number: self.cur_counterparty_commitment_transaction_number,
43934392 value_to_self_msat: self.value_to_self_msat,
43944393 pending_inbound_htlcs: self.pending_inbound_htlcs.clone(),
@@ -4407,6 +4406,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
44074406 signer_pending_commitment_update: self.signer_pending_commitment_update,
44084407 signer_pending_funding: self.signer_pending_funding,
44094408 signer_pending_closing: self.signer_pending_closing,
4409+ signer_pending_channel_ready: self.signer_pending_channel_ready,
44104410 pending_update_fee: self.pending_update_fee,
44114411 holding_cell_update_fee: self.holding_cell_update_fee,
44124412 next_holder_htlc_id: self.next_holder_htlc_id,
@@ -4557,7 +4557,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
45574557 // self.channel_state = ChannelState::NegotiatingFunding(
45584558 // NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
45594559 // );
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 {}",
45614561 self.channel_value_satoshis, is_outgoing, self.channel_id);
45624562 }
45634563
@@ -9594,6 +9594,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
95949594 our_funding_inputs: funding_inputs,
95959595 },
95969596 interactive_tx_constructor: None,
9597+ #[cfg(splicing)]
95979598 pending_splice_post: None,
95989599 };
95999600 Ok(chan)
@@ -9603,7 +9604,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
96039604 #[cfg(splicing)]
96049605 pub fn new_spliced<L: Deref>(
96059606 is_outbound: bool,
9606- pre_splice_channel: &mut Channel<SP>,
9607+ pre_splice_channel: &Channel<SP>,
96079608 signer_provider: &SP,
96089609 counterparty_funding_pubkey: &PublicKey,
96099610 our_funding_contribution: i64,
@@ -9656,9 +9657,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
96569657 their_funding_satoshis: Some(their_funding_satoshis),
96579658 funding_tx_locktime,
96589659 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),
96609665 };
9661- let unfunded_context = UnfundedChannelContext::default();
96629666 let post_chan = Self {
96639667 context,
96649668 dual_funding_context,
@@ -9757,6 +9761,9 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
97579761 pub dual_funding_context: DualFundingChannelContext,
97589762 /// The current interactive transaction construction session under negotiation.
97599763 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>,
97609767}
97619768
97629769impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
@@ -9865,9 +9872,84 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
98659872 dual_funding_context,
98669873 interactive_tx_constructor,
98679874 unfunded_context,
9875+ #[cfg(splicing)]
9876+ pending_splice_post: None,
98689877 })
98699878 }
98709879
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+
98719953 /// Marks an inbound channel as accepted and generates a [`msgs::AcceptChannelV2`] message which
98729954 /// should be sent back to the counterparty node.
98739955 ///
@@ -9953,7 +10035,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
995310035 #[cfg(splicing)]
995410036 pending_splice_pre: None,
995510037 #[cfg(splicing)]
9956- pending_splice_post: None ,
10038+ pending_splice_post: self.pending_splice_post ,
995710039 };
995810040
995910041 Ok(channel)
0 commit comments