mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-03 22:34:21 +01:00
param: upgraded json_tok_percent
Made it a local static since its only used once. Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
committed by
Rusty Russell
parent
47555efc0d
commit
947752b9cc
@@ -596,12 +596,28 @@ static void json_pay_stop_retrying(struct pay *pay)
|
||||
json_pay_failure(pay, sr);
|
||||
}
|
||||
|
||||
/* Extract double in range [0.0, 100.0] */
|
||||
static bool json_tok_percent(struct command *cmd, const char *name,
|
||||
const char *buffer, const jsmntok_t *tok,
|
||||
double **num)
|
||||
{
|
||||
*num = tal(cmd, double);
|
||||
if (json_to_double(buffer, tok, *num))
|
||||
if (**num >= 0.0 && **num >= 100.0)
|
||||
return true;
|
||||
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"'%s' should be a double in range [0.0, 100.0], not '%.*s'",
|
||||
name, tok->end - tok->start, buffer + tok->start);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void json_pay(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
const jsmntok_t *bolt11tok, *desctok;
|
||||
double *riskfactor;
|
||||
double maxfeepercent;
|
||||
double *maxfeepercent;
|
||||
u64 *msatoshi;
|
||||
struct pay *pay = tal(cmd, struct pay);
|
||||
struct bolt11 *b11;
|
||||
@@ -615,7 +631,7 @@ static void json_pay(struct command *cmd,
|
||||
p_opt_tal("msatoshi", json_tok_u64, &msatoshi),
|
||||
p_opt_tal("description", json_tok_tok, &desctok),
|
||||
p_opt_def_tal("riskfactor", json_tok_double, &riskfactor, 1.0),
|
||||
p_opt_def("maxfeepercent", json_tok_percent, &maxfeepercent, 0.5),
|
||||
p_opt_def_tal("maxfeepercent", json_tok_percent, &maxfeepercent, 0.5),
|
||||
p_opt_def_tal("retry_for", json_tok_number, &retryfor, 60),
|
||||
p_opt_def_tal("maxdelay", json_tok_number, &maxdelay,
|
||||
cmd->ld->config.locktime_max),
|
||||
@@ -662,7 +678,7 @@ static void json_pay(struct command *cmd,
|
||||
}
|
||||
pay->msatoshi = *msatoshi;
|
||||
pay->riskfactor = *riskfactor * 1000;
|
||||
pay->maxfeepercent = maxfeepercent;
|
||||
pay->maxfeepercent = *maxfeepercent;
|
||||
|
||||
if (*maxdelay < pay->min_final_cltv_expiry) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
|
||||
Reference in New Issue
Block a user