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

Function bitcoin_tx_compute_fee

bitcoin/tx.c:133–145  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

131 * Compute how much fee we are actually sending with this transaction.
132 */
133struct amount_sat bitcoin_tx_compute_fee(const struct bitcoin_tx *tx)
134{
135 struct amount_sat input_total = AMOUNT_SAT(0), input_amt;
136 bool ok;
137
138 for (size_t i = 0; i < tx->psbt->num_inputs; i++) {
139 input_amt = psbt_input_get_amount(tx->psbt, i);
140 ok = amount_sat_add(&input_total, input_total, input_amt);
141 assert(ok);
142 }
143
144 return bitcoin_tx_compute_fee_w_inputs(tx, input_total);
145}
146
147/*
148 * Add an explicit fee output if necessary.

Callers 2

json_add_channelFunction · 0.85

Calls 3

psbt_input_get_amountFunction · 0.70
amount_sat_addFunction · 0.50

Tested by

no test coverage detected