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

Function fuzzed_near

plugins/libplugin-pay.c:3514–3528  ·  view source on GitHub ↗

Return fuzzed amount ~= target, but never exceeding max */

Source from the content-addressed store, hash-verified

3512
3513/* Return fuzzed amount ~= target, but never exceeding max */
3514static struct amount_msat fuzzed_near(struct amount_msat target,
3515 struct amount_msat max)
3516{
3517 s64 fuzz;
3518 struct amount_msat res = target;
3519
3520 /* Somewhere within 25% of target please. */
3521 fuzz = pseudorand(target.millisatoshis / 2) /* Raw: fuzz */
3522 - target.millisatoshis / 4; /* Raw: fuzz */
3523 res.millisatoshis = target.millisatoshis + fuzz; /* Raw: fuzz < msat */
3524
3525 if (amount_msat_greater(res, max))
3526 res = max;
3527 return res;
3528}
3529
3530static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
3531{

Callers 1

presplit_cbFunction · 0.85

Calls 2

amount_msat_greaterFunction · 0.85
pseudorandFunction · 0.50

Tested by

no test coverage detected