@@ -2440,7 +2440,8 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2440
2440
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
2441
2441
fn begin_interactive_funding_tx_construction<ES: Deref>(
2442
2442
&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)>,
2444
2445
) -> Result<Option<InteractiveTxMessageSend>, AbortReason>
2445
2446
where ES::Target: EntropySource
2446
2447
{
@@ -2450,7 +2451,11 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2450
2451
let mut funding_inputs = Vec::new();
2451
2452
mem::swap(&mut self.funding_negotiation_context.our_funding_inputs, &mut funding_inputs);
2452
2453
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
+ }
2454
2459
2455
2460
// Add output for funding tx
2456
2461
// 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 {
2463
2468
script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
2464
2469
};
2465
2470
2466
- if self.funding.is_outbound() {
2471
+ if is_initiator {
2467
2472
funding_outputs.push(
2468
2473
OutputOwned::Shared(SharedOwnedOutput::new(
2469
2474
shared_funding_output, self.funding_negotiation_context.our_funding_satoshis,
@@ -2482,7 +2487,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2482
2487
.map_err(|_err| AbortReason::InternalError("Error getting destination script"))?
2483
2488
};
2484
2489
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,
2486
2491
&funding_inputs, &funding_outputs,
2487
2492
self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
2488
2493
change_script.minimal_non_dust().to_sat(),
@@ -2508,7 +2513,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2508
2513
counterparty_node_id: self.context.counterparty_node_id,
2509
2514
channel_id: self.context.channel_id(),
2510
2515
feerate_sat_per_kw: self.funding_negotiation_context.funding_feerate_sat_per_1000_weight,
2511
- is_initiator: self.funding.is_outbound() ,
2516
+ is_initiator,
2512
2517
funding_tx_locktime: self.funding_negotiation_context.funding_tx_locktime,
2513
2518
inputs_to_contribute: funding_inputs,
2514
2519
outputs_to_contribute: funding_outputs,
0 commit comments