* inputs_sufficient - are we there yet? * @input: total input amount * @amount: required output amount * @feerate_per_kw: feerate we have to pay * @weight: weight of transaction so far. * @diff: (output) set to amount over or under requirements. * * Returns true if inputs >= fees + amount, otherwise false. diff is * the amount over (if returns true) or under (if returns false) */
| 232 | * the amount over (if returns true) or under (if returns false) |
| 233 | */ |
| 234 | static bool inputs_sufficient(struct amount_sat input, |
| 235 | struct amount_sat amount, |
| 236 | u32 feerate_per_kw, |
| 237 | size_t weight, |
| 238 | struct amount_sat *diff) |
| 239 | { |
| 240 | struct amount_sat fee; |
| 241 | |
| 242 | fee = amount_tx_fee(feerate_per_kw, weight); |
| 243 | |
| 244 | /* If we can't add fees, amount is huge (e.g. "all") */ |
| 245 | if (!amount_sat_add(&amount, amount, fee)) |
| 246 | return false; |
| 247 | |
| 248 | /* One of these must work! */ |
| 249 | if (amount_sat_sub(diff, input, amount)) |
| 250 | return true; |
| 251 | if (!amount_sat_sub(diff, amount, input)) |
| 252 | abort(); |
| 253 | return false; |
| 254 | } |
| 255 | |
| 256 | struct wally_psbt *psbt_using_utxos(const tal_t *ctx, |
| 257 | struct wallet *wallet, |
no test coverage detected