@@ -55,10 +55,12 @@ use crate::ln::channelmanager::{
5555 PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus, RAACommitmentOrder, SentHTLCId,
5656 BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
5757};
58+ #[cfg(splicing)]
59+ use crate::ln::interactivetxs::{calculate_change_output_value, AbortReason};
5860use crate::ln::interactivetxs::{
59- calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteResult ,
60- InteractiveTxConstructor, InteractiveTxConstructorArgs, InteractiveTxMessageSendResult,
61- InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
61+ get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor ,
62+ InteractiveTxConstructorArgs, InteractiveTxMessageSendResult, InteractiveTxSigningSession ,
63+ SharedOwnedInput, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
6264};
6365use crate::ln::msgs;
6466use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket};
@@ -5807,6 +5809,9 @@ pub(super) struct FundingNegotiationContext {
58075809 /// The feerate set by the initiator to be used for the funding transaction.
58085810 #[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
58095811 pub funding_feerate_sat_per_1000_weight: u32,
5812+ /// The input spending the previous funding output, if this is a splice.
5813+ #[allow(dead_code)] // TODO(splicing): Remove once splicing is enabled.
5814+ pub shared_funding_input: Option<SharedOwnedInput>,
58105815 /// The funding inputs we will be contributing to the channel.
58115816 #[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
58125817 pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
@@ -5821,13 +5826,17 @@ impl FundingNegotiationContext {
58215826 fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
58225827 self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
58235828 entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5824- shared_funding_input: Option<SharedOwnedInput>,
58255829 ) -> Result<InteractiveTxConstructor, AbortReason>
58265830 where
58275831 SP::Target: SignerProvider,
58285832 ES::Target: EntropySource,
58295833 {
5830- if shared_funding_input.is_some() {
5834+ debug_assert_eq!(
5835+ self.shared_funding_input.is_some(),
5836+ funding.channel_transaction_parameters.splice_parent_funding_txid.is_some(),
5837+ );
5838+
5839+ if self.shared_funding_input.is_some() {
58315840 debug_assert!(matches!(context.channel_state, ChannelState::ChannelReady(_)));
58325841 } else {
58335842 debug_assert!(matches!(context.channel_state, ChannelState::NegotiatingFunding(_)));
@@ -5847,7 +5856,7 @@ impl FundingNegotiationContext {
58475856 if self.our_funding_contribution_satoshis > 0 {
58485857 let change_value_opt = calculate_change_output_value(
58495858 &self,
5850- funding.channel_transaction_parameters.splice_parent_funding_txid .is_some(),
5859+ self.shared_funding_input .is_some(),
58515860 &shared_funding_output.script_pubkey,
58525861 &funding_outputs,
58535862 context.holder_dust_limit_satoshis,
@@ -5884,7 +5893,7 @@ impl FundingNegotiationContext {
58845893 is_initiator: self.is_initiator,
58855894 funding_tx_locktime: self.funding_tx_locktime,
58865895 inputs_to_contribute: self.our_funding_inputs,
5887- shared_funding_input,
5896+ shared_funding_input: self.shared_funding_input ,
58885897 shared_funding_output: SharedOwnedOutput::new(
58895898 shared_funding_output,
58905899 funding.value_to_self_msat / 1000,
@@ -12115,6 +12124,7 @@ where
1211512124 their_funding_contribution_satoshis: None,
1211612125 funding_tx_locktime,
1211712126 funding_feerate_sat_per_1000_weight,
12127+ shared_funding_input: None,
1211812128 our_funding_inputs: funding_inputs,
1211912129 };
1212012130 let chan = Self {
@@ -12269,6 +12279,7 @@ where
1226912279 their_funding_contribution_satoshis: Some(msg.common_fields.funding_satoshis as i64),
1227012280 funding_tx_locktime: LockTime::from_consensus(msg.locktime),
1227112281 funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12282+ shared_funding_input: None,
1227212283 our_funding_inputs: our_funding_inputs.clone(),
1227312284 };
1227412285 let shared_funding_output = TxOut {
0 commit comments