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

Function bitcoin_tx_compute_fee

bitcoin/tx.c:143–155  ·  view source on GitHub ↗

* Compute how much fee we are actually sending with this transaction. */

Source from the content-addressed store, hash-verified

141 * Compute how much fee we are actually sending with this transaction.
142 */
143struct amount_sat bitcoin_tx_compute_fee(const struct bitcoin_tx *tx)
144{
145 struct amount_sat input_total = AMOUNT_SAT(0), input_amt;
146 bool ok;
147
148 for (size_t i = 0; i < tx->psbt->num_inputs; i++) {
149 input_amt = psbt_input_get_amount(tx->psbt, i);
150 ok = amount_sat_add(&input_total, input_total, input_amt);
151 assert(ok);
152 }
153
154 return bitcoin_tx_compute_fee_w_inputs(tx, input_total);
155}
156
157/*
158 * Add an explicit fee output if necessary.

Callers 8

tx_feerateFunction · 0.85
send_commit_partFunction · 0.85
NON_NULL_ARGSFunction · 0.85
create_anchor_detailsFunction · 0.85
json_add_closed_channelFunction · 0.85

Calls 3

psbt_input_get_amountFunction · 0.85
amount_sat_addFunction · 0.50

Tested by

no test coverage detected