lightningd: remove deprecated_apis global, put into lightningd.

We usually have access to `ld`, so avoid the global.

The only place generic code needs it is for the json command struct,
and that already has accessors: add one for libplugin and lightningd
to tell it if deprecated apis are OK.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-06 17:06:50 +09:30
parent db7c608e2d
commit 0c4426a349
28 changed files with 80 additions and 59 deletions

View File

@@ -115,7 +115,8 @@ static struct command_result *parse_by_position(struct command *cmd,
return post_check(cmd, params);
}
static struct param *find_param(struct param *params, const char *start,
static struct param *find_param(struct command *cmd,
struct param *params, const char *start,
size_t n)
{
struct param *first = params;
@@ -125,11 +126,11 @@ static struct param *find_param(struct param *params, const char *start,
size_t arglen = strcspn(first->name, "|");
if (memeq(first->name, arglen, start, n))
return first;
if (deprecated_apis
&& first->name[arglen]
if (first->name[arglen]
&& memeq(first->name + arglen + 1,
strlen(first->name + arglen + 1),
start, n))
start, n)
&& command_deprecated_apis(cmd))
return first;
first++;
}
@@ -146,7 +147,7 @@ static struct command_result *parse_by_name(struct command *cmd,
const jsmntok_t *t;
json_for_each_obj(i, t, tokens) {
struct param *p = find_param(params, buffer + t->start,
struct param *p = find_param(cmd, params, buffer + t->start,
t->end - t->start);
if (!p) {
if (!allow_extra) {