MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitcoin_tx_add_output

Function bitcoin_tx_add_output

bitcoin/tx.c:62–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
63 const u8 *wscript, struct amount_sat amount)
64{
65 size_t i = tx->wtx->num_outputs;
66 struct wally_tx_output *output;
67 struct wally_psbt_output *psbt_out;
68 int ret;
69 const struct chainparams *chainparams = tx->chainparams;
70 assert(i < tx->wtx->outputs_allocation_len);
71
72 assert(tx->wtx != NULL);
73 assert(chainparams);
74
75 output = wally_tx_output(NULL, script, amount);
76 assert(output);
77 tal_wally_start();
78 ret = wally_tx_add_output(tx->wtx, output);
79 assert(ret == WALLY_OK);
80 tal_wally_end(tx->wtx);
81
82 psbt_out = psbt_add_output(tx->psbt, output, i);
83 if (wscript) {
84 tal_wally_start();
85 ret = wally_psbt_output_set_witness_script(psbt_out,
86 wscript,
87 tal_bytelen(wscript));
88 assert(ret == WALLY_OK);
89 tal_wally_end(tx->psbt);
90 }
91
92 wally_tx_output_free(output);
93 bitcoin_tx_output_set_amount(tx, i, amount);
94
95 return i;
96}
97
98void bitcoin_tx_remove_output(struct bitcoin_tx *tx, size_t outnum)
99{

Callers 12

add_offered_htlc_outFunction · 0.85
add_received_htlc_outFunction · 0.85
commit_txFunction · 0.85
penalty_tx_createFunction · 0.85
onchaind_tx_unsignedFunction · 0.85
tx_add_anchor_outputFunction · 0.85
initial_commit_txFunction · 0.85
htlc_txFunction · 0.85
create_close_txFunction · 0.85
funding_txFunction · 0.85
mainFunction · 0.85

Calls 6

tal_wally_startFunction · 0.85
tal_wally_endFunction · 0.85
psbt_add_outputFunction · 0.85
tal_bytelenFunction · 0.85
wally_tx_outputFunction · 0.70

Tested by

no test coverage detected