From fb0a1c64fd39aeef2c570fde98e5b67881469834 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 25 Jan 2024 10:58:56 +1030 Subject: [PATCH] libplugin: get `i-promise-to-fix-broken-api-user` list from lightningd. This means it now covers plugin parameters too. Signed-off-by: Rusty Russell --- plugins/libplugin.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index db7b8c160..f9f44e01e 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -50,6 +50,9 @@ struct plugin { /* to append to all our command ids */ const char *id; + /* options to i-promise-to-fix-broken-api-user */ + const char **beglist; + /* To read from lightningd */ char *buffer; size_t used, len_read; @@ -171,8 +174,7 @@ bool command_deprecated_in_named_ok(struct command *cmd, ? tal_fmt(tmpctx, "%s.%s", cmdname, param) : cmdname, depr_start, depr_end, - /* FIXME: Get api begs from lightningd! */ - NULL, + cmd->plugin->beglist, complain_deprecated, cmd); } @@ -1224,6 +1226,18 @@ static struct plugin_option *find_opt(struct plugin *plugin, const char *name) return NULL; } +static const char **json_to_apilist(const tal_t *ctx, const char *buffer, const jsmntok_t *tok) +{ + size_t i; + const jsmntok_t *t; + const char **ret = tal_arr(ctx, const char *, tok->size); + + json_for_each_arr(i, t, tok) + ret[i] = json_strdup(ret, buffer, t); + + return ret; +} + static struct command_result *handle_init(struct command *cmd, const char *buf, const jsmntok_t *params) @@ -1305,8 +1319,14 @@ static struct command_result *handle_init(struct command *cmd, disable)); } - if (with_rpc) + if (with_rpc) { + p->beglist = NULL; + rpc_scan(p, "listconfigs", + take(json_out_obj(NULL, "config", "i-promise-to-fix-broken-api-user")), + "{configs:{i-promise-to-fix-broken-api-user?:%}}", + JSON_SCAN_TAL(p, json_to_apilist, &p->beglist)); io_new_conn(p, p->rpc_conn->fd, rpc_conn_init, p); + } return command_success(cmd, json_out_obj(cmd, NULL, NULL)); }