Skip to content

Commit c454c96

Browse files
optout21dunxen
authored andcommitted
Add Shared Input support
1 parent 369dbce commit c454c96

File tree

4 files changed

+541
-140
lines changed

4 files changed

+541
-140
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,8 @@ where
27982798
};
27992799
let change_value_opt = calculate_change_output_value(
28002800
self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
2801-
&shared_funding_output.script_pubkey, &funding_inputs, &funding_outputs,
2801+
&funding_inputs, None,
2802+
&shared_funding_output.script_pubkey, &funding_outputs,
28022803
self.dual_funding_context.funding_feerate_sat_per_1000_weight,
28032804
change_script.minimal_non_dust().to_sat(),
28042805
)?;
@@ -2826,6 +2827,7 @@ where
28262827
is_initiator: self.funding.is_outbound(),
28272828
funding_tx_locktime: self.dual_funding_context.funding_tx_locktime,
28282829
inputs_to_contribute: funding_inputs,
2830+
shared_funding_input: None,
28292831
shared_funding_output: (shared_funding_output, self.dual_funding_context.our_funding_satoshis),
28302832
outputs_to_contribute: funding_outputs,
28312833
};
@@ -12069,6 +12071,7 @@ where
1206912071
funding_tx_locktime: dual_funding_context.funding_tx_locktime,
1207012072
is_initiator: false,
1207112073
inputs_to_contribute: our_funding_inputs,
12074+
shared_funding_input: None,
1207212075
shared_funding_output: (shared_funding_output, our_funding_satoshis),
1207312076
outputs_to_contribute: Vec::new(),
1207412077
}

lightning/src/ln/dual_funding_tests.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
8989
let tx_add_input_msg = TxAddInput {
9090
channel_id,
9191
serial_id: 2, // Even serial_id from initiator.
92-
prevtx: initiator_funding_inputs[0].1.clone(),
92+
prevtx: Some(initiator_funding_inputs[0].1.clone()),
9393
prevtx_out: 0,
9494
sequence: initiator_funding_inputs[0].0.sequence.0,
9595
shared_input_txid: None,
9696
};
97-
let input_value =
98-
tx_add_input_msg.prevtx.as_transaction().output[tx_add_input_msg.prevtx_out as usize].value;
97+
let input_value = tx_add_input_msg.prevtx.as_ref().unwrap().as_transaction().output
98+
[tx_add_input_msg.prevtx_out as usize]
99+
.value;
99100
assert_eq!(input_value.to_sat(), session.initiator_input_value_satoshis);
100101

101102
nodes[1].node.handle_tx_add_input(nodes[0].node.get_our_node_id(), &tx_add_input_msg);

0 commit comments

Comments
 (0)