| 107 | } |
| 108 | |
| 109 | struct 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. |
no test coverage detected