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

Function inputs_sufficient

wallet/reservation.c:234–254  ·  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

232 * the amount over (if returns true) or under (if returns false)
233 */
234static 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
256struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
257 struct wallet *wallet,

Callers 3

json_fundpsbtFunction · 0.85
json_addpsbtinputFunction · 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