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:109–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109struct amount_sat bitcoin_tx_compute_fee_w_inputs(const struct bitcoin_tx *tx,
110 struct amount_sat input_val)
111{
112 struct amount_asset asset;
113 bool ok;
114
115 for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
116 asset = bitcoin_tx_output_get_amount(tx, i);
117 if (elements_tx_output_is_fee(tx, i) ||
118 !amount_asset_is_main(&asset))
119 continue;
120
121 ok = amount_sat_sub(&input_val, input_val,
122 amount_asset_to_sat(&asset));
123 if (!ok)
124 return AMOUNT_SAT(0);
125
126 }
127 return input_val;
128}
129
130/**
131 * 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