Skip to content

Commit 1a193c7

Browse files
committed
Extend begin_interactive_...() with splicing-specific parameters
The begin_interactive_funding_tx_construction() method is extended with `is_initiator` parameter (splice initiator), and `prev_funding_input` optional parameter, containing the previous funding transaction, which will be added to the negotiation as an input by the initiator.
1 parent 0b89a36 commit 1a193c7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,8 @@ where
27062706
#[rustfmt::skip]
27072707
fn begin_interactive_funding_tx_construction<ES: Deref>(
27082708
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
2709-
change_destination_opt: Option<ScriptBuf>,
2709+
is_initiator: bool, change_destination_opt: Option<ScriptBuf>,
2710+
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
27102711
) -> Result<Option<InteractiveTxMessageSend>, AbortReason>
27112712
where ES::Target: EntropySource
27122713
{
@@ -2716,7 +2717,11 @@ where
27162717
let mut funding_inputs = Vec::new();
27172718
mem::swap(&mut self.funding_negotiation_context.our_funding_inputs, &mut funding_inputs);
27182719

2719-
// TODO(splicing): Add prev funding tx as input, must be provided as a parameter
2720+
if is_initiator {
2721+
if let Some(prev_funding_input) = prev_funding_input {
2722+
funding_inputs.push(prev_funding_input);
2723+
}
2724+
}
27202725

27212726
// Add output for funding tx
27222727
// Note: For the error case when the inputs are insufficient, it will be handled after
@@ -2729,7 +2734,7 @@ where
27292734
script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
27302735
};
27312736

2732-
if self.funding.is_outbound() {
2737+
if is_initiator {
27332738
funding_outputs.push(
27342739
OutputOwned::Shared(SharedOwnedOutput::new(
27352740
shared_funding_output, self.funding_negotiation_context.our_funding_satoshis,
@@ -2748,7 +2753,7 @@ where
27482753
.map_err(|_err| AbortReason::InternalError("Error getting destination script"))?
27492754
};
27502755
let change_value_opt = calculate_change_output_value(
2751-
self.funding.is_outbound(), self.funding_negotiation_context.our_funding_satoshis,
2756+
is_initiator, self.funding_negotiation_context.our_funding_satoshis,
27522757
&funding_inputs, &funding_outputs,
27532758
self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
27542759
change_script.minimal_non_dust().to_sat(),
@@ -2774,7 +2779,7 @@ where
27742779
counterparty_node_id: self.context.counterparty_node_id,
27752780
channel_id: self.context.channel_id(),
27762781
feerate_sat_per_kw: self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
2777-
is_initiator: self.funding.is_outbound(),
2782+
is_initiator,
27782783
funding_tx_locktime: self.funding_negotiation_context.funding_tx_locktime,
27792784
inputs_to_contribute: funding_inputs,
27802785
outputs_to_contribute: funding_outputs,

0 commit comments

Comments
 (0)