Skip to content

Commit d915f6e

Browse files
committed
Add shared_funding_input to FundingNegotiationContext
Instead of passing the shared funding input as another parameter to FundingNegotiationContext::into_interactive_tx_constructor, make it a member of FundingNegotiationContext.
1 parent 55049ae commit d915f6e

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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};
5860
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,
6264
};
6365
use crate::ln::msgs;
6466
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket};
@@ -5804,6 +5806,9 @@ pub(super) struct FundingNegotiationContext {
58045806
/// The feerate set by the initiator to be used for the funding transaction.
58055807
#[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
58065808
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>,
58075812
/// The funding inputs we will be contributing to the channel.
58085813
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
58095814
pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
@@ -5818,13 +5823,17 @@ impl FundingNegotiationContext {
58185823
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
58195824
self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
58205825
entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5821-
shared_funding_input: Option<SharedOwnedInput>,
58225826
) -> Result<InteractiveTxConstructor, AbortReason>
58235827
where
58245828
SP::Target: SignerProvider,
58255829
ES::Target: EntropySource,
58265830
{
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() {
58285837
debug_assert!(matches!(context.channel_state, ChannelState::ChannelReady(_)));
58295838
} else {
58305839
debug_assert!(matches!(context.channel_state, ChannelState::NegotiatingFunding(_)));
@@ -5844,7 +5853,7 @@ impl FundingNegotiationContext {
58445853
if self.our_funding_contribution_satoshis > 0 {
58455854
let change_value_opt = calculate_change_output_value(
58465855
&self,
5847-
funding.channel_transaction_parameters.splice_parent_funding_txid.is_some(),
5856+
self.shared_funding_input.is_some(),
58485857
&shared_funding_output.script_pubkey,
58495858
&funding_outputs,
58505859
context.holder_dust_limit_satoshis,
@@ -5881,7 +5890,7 @@ impl FundingNegotiationContext {
58815890
is_initiator: self.is_initiator,
58825891
funding_tx_locktime: self.funding_tx_locktime,
58835892
inputs_to_contribute: self.our_funding_inputs,
5884-
shared_funding_input,
5893+
shared_funding_input: self.shared_funding_input,
58855894
shared_funding_output: SharedOwnedOutput::new(
58865895
shared_funding_output,
58875896
funding.value_to_self_msat / 1000,
@@ -12109,6 +12118,7 @@ where
1210912118
their_funding_contribution_satoshis: None,
1211012119
funding_tx_locktime,
1211112120
funding_feerate_sat_per_1000_weight,
12121+
shared_funding_input: None,
1211212122
our_funding_inputs: funding_inputs,
1211312123
};
1211412124
let chan = Self {
@@ -12263,6 +12273,7 @@ where
1226312273
their_funding_contribution_satoshis: Some(msg.common_fields.funding_satoshis as i64),
1226412274
funding_tx_locktime: LockTime::from_consensus(msg.locktime),
1226512275
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12276+
shared_funding_input: None,
1226612277
our_funding_inputs: our_funding_inputs.clone(),
1226712278
};
1226812279
let shared_funding_output = TxOut {

lightning/src/ln/interactivetxs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,7 @@ mod tests {
29772977
their_funding_contribution_satoshis: None,
29782978
funding_tx_locktime: AbsoluteLockTime::ZERO,
29792979
funding_feerate_sat_per_1000_weight,
2980+
shared_funding_input: None,
29802981
our_funding_inputs: inputs,
29812982
};
29822983
assert_eq!(

0 commit comments

Comments
 (0)