* Compute how much fee we are actually sending with this transaction. */
| 131 | * Compute how much fee we are actually sending with this transaction. |
| 132 | */ |
| 133 | struct 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. |
no test coverage detected