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

Function bitcoin_tx_add_output

bitcoin/tx.c:61–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 13

tx_to_usFunction · 0.85
replace_penalty_tx_to_usFunction · 0.85
add_offered_htlc_outFunction · 0.85
add_received_htlc_outFunction · 0.85
commit_txFunction · 0.85
penalty_tx_createFunction · 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

Calls 6

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

Tested by

no test coverage detected