@@ -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};
@@ -5807,6 +5809,9 @@ pub(super) struct FundingNegotiationContext {
5807
5809
/// The feerate set by the initiator to be used for the funding transaction.
5808
5810
#[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
5809
5811
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>,
5810
5815
/// The funding inputs we will be contributing to the channel.
5811
5816
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
5812
5817
pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
@@ -5821,13 +5826,17 @@ impl FundingNegotiationContext {
5821
5826
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
5822
5827
self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
5823
5828
entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5824
- shared_funding_input: Option<SharedOwnedInput>,
5825
5829
) -> Result<InteractiveTxConstructor, AbortReason>
5826
5830
where
5827
5831
SP::Target: SignerProvider,
5828
5832
ES::Target: EntropySource,
5829
5833
{
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() {
5831
5840
debug_assert!(matches!(context.channel_state, ChannelState::ChannelReady(_)));
5832
5841
} else {
5833
5842
debug_assert!(matches!(context.channel_state, ChannelState::NegotiatingFunding(_)));
@@ -5847,7 +5856,7 @@ impl FundingNegotiationContext {
5847
5856
if self.our_funding_contribution_satoshis > 0 {
5848
5857
let change_value_opt = calculate_change_output_value(
5849
5858
&self,
5850
- funding.channel_transaction_parameters.splice_parent_funding_txid .is_some(),
5859
+ self.shared_funding_input .is_some(),
5851
5860
&shared_funding_output.script_pubkey,
5852
5861
&funding_outputs,
5853
5862
context.holder_dust_limit_satoshis,
@@ -5884,7 +5893,7 @@ impl FundingNegotiationContext {
5884
5893
is_initiator: self.is_initiator,
5885
5894
funding_tx_locktime: self.funding_tx_locktime,
5886
5895
inputs_to_contribute: self.our_funding_inputs,
5887
- shared_funding_input,
5896
+ shared_funding_input: self.shared_funding_input ,
5888
5897
shared_funding_output: SharedOwnedOutput::new(
5889
5898
shared_funding_output,
5890
5899
funding.value_to_self_msat / 1000,
@@ -12115,6 +12124,7 @@ where
12115
12124
their_funding_contribution_satoshis: None,
12116
12125
funding_tx_locktime,
12117
12126
funding_feerate_sat_per_1000_weight,
12127
+ shared_funding_input: None,
12118
12128
our_funding_inputs: funding_inputs,
12119
12129
};
12120
12130
let chan = Self {
@@ -12269,6 +12279,7 @@ where
12269
12279
their_funding_contribution_satoshis: Some(msg.common_fields.funding_satoshis as i64),
12270
12280
funding_tx_locktime: LockTime::from_consensus(msg.locktime),
12271
12281
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12282
+ shared_funding_input: None,
12272
12283
our_funding_inputs: our_funding_inputs.clone(),
12273
12284
};
12274
12285
let shared_funding_output = TxOut {
0 commit comments