mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
df: move out logic for adding funding output to PSBT
This commit is contained in:
parent
804b93c81f
commit
e67d5d7559
@ -1916,6 +1916,27 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
handle_send_tx_sigs(state, msg);
|
||||
}
|
||||
|
||||
static void add_funding_output(struct tx_state *tx_state,
|
||||
struct state *state,
|
||||
struct amount_sat total)
|
||||
{
|
||||
const u8 *wscript;
|
||||
struct wally_psbt_output *funding_out;
|
||||
|
||||
wscript = bitcoin_redeem_2of2(tmpctx, &state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey);
|
||||
funding_out = psbt_append_output(tx_state->psbt,
|
||||
scriptpubkey_p2wsh(tmpctx, wscript),
|
||||
total);
|
||||
|
||||
/* Add a serial_id for this output */
|
||||
tx_state->funding_serial = psbt_new_input_serial(tx_state->psbt,
|
||||
TX_INITIATOR);
|
||||
psbt_output_set_serial_id(tx_state->psbt,
|
||||
funding_out,
|
||||
tx_state->funding_serial);
|
||||
}
|
||||
|
||||
static void opener_start(struct state *state, u8 *msg)
|
||||
{
|
||||
struct tlv_opening_tlvs *open_tlv;
|
||||
@ -1924,7 +1945,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
char *err_reason;
|
||||
struct amount_sat total;
|
||||
struct amount_msat our_msats;
|
||||
struct wally_psbt_output *funding_out;
|
||||
struct sha256 podle;
|
||||
struct wally_tx_output *direct_outputs[NUM_SIDES];
|
||||
struct penalty_base *pbase;
|
||||
@ -2121,21 +2141,7 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
* - MUST send at least one `tx_add_output`, the channel
|
||||
* funding output.
|
||||
*/
|
||||
/* If fails before returning from `send_next`, this will
|
||||
* be marked as a memleak */
|
||||
wscript = notleak(bitcoin_redeem_2of2(state,
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey));
|
||||
funding_out = psbt_append_output(tx_state->psbt,
|
||||
scriptpubkey_p2wsh(tmpctx,
|
||||
wscript),
|
||||
total);
|
||||
/* Add a serial_id for this output */
|
||||
tx_state->funding_serial = psbt_new_input_serial(tx_state->psbt,
|
||||
TX_INITIATOR);
|
||||
psbt_output_set_serial_id(tx_state->psbt,
|
||||
funding_out,
|
||||
tx_state->funding_serial);
|
||||
add_funding_output(tx_state, state, total);
|
||||
|
||||
/* Add all of our inputs/outputs to the changeset */
|
||||
init_changeset(tx_state, tx_state->psbt);
|
||||
|
Loading…
Reference in New Issue
Block a user