@@ -55,10 +55,12 @@ use crate::ln::channelmanager::{
55
55
PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus, RAACommitmentOrder, SentHTLCId,
56
56
BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
57
57
};
58
+ #[cfg(splicing)]
59
+ use crate::ln::interactivetxs::{calculate_change_output_value, AbortReason};
58
60
use 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,
62
64
};
63
65
use crate::ln::msgs;
64
66
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket};
@@ -5804,6 +5806,9 @@ pub(super) struct FundingNegotiationContext {
5804
5806
/// The feerate set by the initiator to be used for the funding transaction.
5805
5807
#[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
5806
5808
pub funding_feerate_sat_per_1000_weight: u32,
5809
+ /// The input spending the previous funding output, if this is a splice.
5810
+ #[allow(dead_code)] // TODO(splicing): Remove once splicing is enabled.
5811
+ pub shared_funding_input: Option<SharedOwnedInput>,
5807
5812
/// The funding inputs we will be contributing to the channel.
5808
5813
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
5809
5814
pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
@@ -5818,13 +5823,17 @@ impl FundingNegotiationContext {
5818
5823
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
5819
5824
self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
5820
5825
entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5821
- shared_funding_input: Option<SharedOwnedInput>,
5822
5826
) -> Result<InteractiveTxConstructor, AbortReason>
5823
5827
where
5824
5828
SP::Target: SignerProvider,
5825
5829
ES::Target: EntropySource,
5826
5830
{
5827
- if shared_funding_input.is_some() {
5831
+ debug_assert_eq!(
5832
+ self.shared_funding_input.is_some(),
5833
+ funding.channel_transaction_parameters.splice_parent_funding_txid.is_some(),
5834
+ );
5835
+
5836
+ if self.shared_funding_input.is_some() {
5828
5837
debug_assert!(matches!(context.channel_state, ChannelState::ChannelReady(_)));
5829
5838
} else {
5830
5839
debug_assert!(matches!(context.channel_state, ChannelState::NegotiatingFunding(_)));
@@ -5844,7 +5853,7 @@ impl FundingNegotiationContext {
5844
5853
if self.our_funding_contribution_satoshis > 0 {
5845
5854
let change_value_opt = calculate_change_output_value(
5846
5855
&self,
5847
- funding.channel_transaction_parameters.splice_parent_funding_txid .is_some(),
5856
+ self.shared_funding_input .is_some(),
5848
5857
&shared_funding_output.script_pubkey,
5849
5858
&funding_outputs,
5850
5859
context.holder_dust_limit_satoshis,
@@ -5881,7 +5890,7 @@ impl FundingNegotiationContext {
5881
5890
is_initiator: self.is_initiator,
5882
5891
funding_tx_locktime: self.funding_tx_locktime,
5883
5892
inputs_to_contribute: self.our_funding_inputs,
5884
- shared_funding_input,
5893
+ shared_funding_input: self.shared_funding_input ,
5885
5894
shared_funding_output: SharedOwnedOutput::new(
5886
5895
shared_funding_output,
5887
5896
funding.value_to_self_msat / 1000,
@@ -12109,6 +12118,7 @@ where
12109
12118
their_funding_contribution_satoshis: None,
12110
12119
funding_tx_locktime,
12111
12120
funding_feerate_sat_per_1000_weight,
12121
+ shared_funding_input: None,
12112
12122
our_funding_inputs: funding_inputs,
12113
12123
};
12114
12124
let chan = Self {
@@ -12263,6 +12273,7 @@ where
12263
12273
their_funding_contribution_satoshis: Some(msg.common_fields.funding_satoshis as i64),
12264
12274
funding_tx_locktime: LockTime::from_consensus(msg.locktime),
12265
12275
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12276
+ shared_funding_input: None,
12266
12277
our_funding_inputs: our_funding_inputs.clone(),
12267
12278
};
12268
12279
let shared_funding_output = TxOut {
0 commit comments