* 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) */
| 222 | * the amount over (if returns true) or under (if returns false) |
| 223 | */ |
| 224 | static bool inputs_sufficient(struct amount_sat input, |
| 225 | struct amount_sat amount, |
| 226 | u32 feerate_per_kw, |
| 227 | size_t weight, |
| 228 | struct amount_sat *diff) |
| 229 | { |
| 230 | struct amount_sat fee; |
| 231 | |
| 232 | fee = amount_tx_fee(feerate_per_kw, weight); |
| 233 | |
| 234 | /* If we can't add fees, amount is huge (e.g. "all") */ |
| 235 | if (!amount_sat_add(&amount, amount, fee)) |
| 236 | return false; |
| 237 | |
| 238 | /* One of these must work! */ |
| 239 | if (amount_sat_sub(diff, input, amount)) |
| 240 | return true; |
| 241 | if (!amount_sat_sub(diff, amount, input)) |
| 242 | abort(); |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | static struct wally_psbt *psbt_using_utxos(const tal_t *ctx, |
| 247 | struct wallet *wallet, |
no test coverage detected