MCPcopy Create free account
hub / github.com/ElementsProject/lightning / inputs_sufficient

Function inputs_sufficient

wallet/reservation.c:224–244  ·  view source on GitHub ↗

* 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) */

Source from the content-addressed store, hash-verified

222 * the amount over (if returns true) or under (if returns false)
223 */
224static 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
246static struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
247 struct wallet *wallet,

Callers 2

json_fundpsbtFunction · 0.85
json_utxopsbtFunction · 0.85

Calls 4

abortFunction · 0.85
amount_tx_feeFunction · 0.50
amount_sat_addFunction · 0.50
amount_sat_subFunction · 0.50

Tested by

no test coverage detected