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

Function bitcoin_tx_compute_fee_w_inputs

bitcoin/tx.c:119–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119struct amount_sat bitcoin_tx_compute_fee_w_inputs(const struct bitcoin_tx *tx,
120 struct amount_sat input_val)
121{
122 struct amount_asset asset;
123 bool ok;
124
125 for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
126 asset = bitcoin_tx_output_get_amount(tx, i);
127 if (elements_tx_output_is_fee(tx, i) ||
128 !amount_asset_is_main(&asset))
129 continue;
130
131 ok = amount_sat_sub(&input_val, input_val,
132 amount_asset_to_sat(&asset));
133 if (!ok)
134 return AMOUNT_SAT(0);
135
136 }
137 return input_val;
138}
139
140/**
141 * Compute how much fee we are actually sending with this transaction.

Callers 1

bitcoin_tx_compute_feeFunction · 0.85

Calls 5

amount_asset_is_mainFunction · 0.50
amount_sat_subFunction · 0.50
amount_asset_to_satFunction · 0.50

Tested by

no test coverage detected