| 117 | } |
| 118 | |
| 119 | struct 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. |
no test coverage detected