Skip to content

Commit 7bce024

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 07651d5 commit 7bce024

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
@@ -2440,7 +2440,8 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
24402440
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
24412441
fn begin_interactive_funding_tx_construction<ES: Deref>(
24422442
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
2443-
change_destination_opt: Option<ScriptBuf>,
2443+
is_initiator: bool, change_destination_opt: Option<ScriptBuf>,
2444+
prev_funding_input: Option<(TxIn, TransactionU16LenLimited)>,
24442445
) -> Result<Option<InteractiveTxMessageSend>, AbortReason>
24452446
where ES::Target: EntropySource
24462447
{
@@ -2450,7 +2451,11 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
24502451
let mut funding_inputs = Vec::new();
24512452
mem::swap(&mut self.funding_negotiation_context.our_funding_inputs, &mut funding_inputs);
24522453

2453-
// TODO(splicing): Add prev funding tx as input, must be provided as a parameter
2454+
if is_initiator {
2455+
if let Some(prev_funding_input) = prev_funding_input {
2456+
funding_inputs.push(prev_funding_input);
2457+
}
2458+
}
24542459

24552460
// Add output for funding tx
24562461
// Note: For the error case when the inputs are insufficient, it will be handled after
@@ -2463,7 +2468,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
24632468
script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
24642469
};
24652470

2466-
if self.funding.is_outbound() {
2471+
if is_initiator {
24672472
funding_outputs.push(
24682473
OutputOwned::Shared(SharedOwnedOutput::new(
24692474
shared_funding_output, self.funding_negotiation_context.our_funding_satoshis,
@@ -2482,7 +2487,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
24822487
.map_err(|_err| AbortReason::InternalError("Error getting destination script"))?
24832488
};
24842489
let change_value_opt = calculate_change_output_value(
2485-
self.funding.is_outbound(), self.funding_negotiation_context.our_funding_satoshis,
2490+
is_initiator, self.funding_negotiation_context.our_funding_satoshis,
24862491
&funding_inputs, &funding_outputs,
24872492
self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
24882493
change_script.minimal_non_dust().to_sat(),
@@ -2508,7 +2513,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
25082513
counterparty_node_id: self.context.counterparty_node_id,
25092514
channel_id: self.context.channel_id(),
25102515
feerate_sat_per_kw: self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
2511-
is_initiator: self.funding.is_outbound(),
2516+
is_initiator,
25122517
funding_tx_locktime: self.funding_negotiation_context.funding_tx_locktime,
25132518
inputs_to_contribute: funding_inputs,
25142519
outputs_to_contribute: funding_outputs,

0 commit comments

Comments
 (0)