From 040af90e7d5b0186beecc8cf904291da46702487 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 25 Jan 2024 10:58:56 +1030 Subject: [PATCH] libplugin: remove global deprecated_apis flag. And we don't need to handle 0.9 lightningd which didn't include allow-deprecated-apis in getmanifest call. Signed-off-by: Rusty Russell --- plugins/libplugin.c | 27 ++++++++++++--------------- plugins/libplugin.h | 2 -- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 1efb35a56f4c..a2acab60485c 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -21,8 +21,6 @@ #define READ_CHUNKSIZE 4096 -bool deprecated_apis; - struct plugin_timer { struct timer timer; void (*cb)(void *cb_arg); @@ -48,7 +46,10 @@ struct plugin { /* Are we in developer mode? */ bool developer; - /* Is this command overriding the global deprecated_apis? */ + /* Global deprecations enabled? */ + bool deprecated_ok; + + /* Is this command overriding global deprecated_ok? */ bool *deprecated_ok_override; /* to append to all our command ids */ @@ -167,7 +168,7 @@ bool command_deprecated_in_nocmd_ok(struct plugin *plugin, const char *depr_start, const char *depr_end) { - return deprecated_ok(deprecated_apis, + return deprecated_ok(plugin->deprecated_ok, name, depr_start, depr_end, plugin->beglist, @@ -1001,18 +1002,14 @@ handle_getmanifest(struct command *getmanifest_cmd, { struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd); struct plugin *p = getmanifest_cmd->plugin; - const jsmntok_t *dep; bool has_shutdown_notif; - /* This was added post 0.9.0 */ - dep = json_get_member(buf, getmanifest_params, "allow-deprecated-apis"); - if (!dep) - deprecated_apis = true; - else { - if (!json_to_bool(buf, dep, &deprecated_apis)) - plugin_err(p, "Invalid allow-deprecated-apis '%.*s'", - json_tok_full_len(dep), - json_tok_full(buf, dep)); + if (json_scan(tmpctx, buf, getmanifest_params, + "{allow-deprecated-apis:%}", + JSON_SCAN(json_to_bool, &p->deprecated_ok)) != NULL) { + plugin_err(p, "Invalid allow-deprecated-apis in '%.*s'", + json_tok_full_len(getmanifest_params), + json_tok_full(buf, getmanifest_params)); } json_array_start(params, "options"); @@ -1676,7 +1673,7 @@ bool command_deprecated_ok_flag(const struct command *cmd) { if (cmd->plugin->deprecated_ok_override) return *cmd->plugin->deprecated_ok_override; - return deprecated_apis; + return cmd->plugin->deprecated_ok; } static void ld_command_handle(struct plugin *plugin, diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 2f8e047a31fe..6f63e42149ff 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -24,8 +24,6 @@ struct htable; struct plugin; struct rpc_conn; -extern bool deprecated_apis; - enum plugin_restartability { PLUGIN_STATIC, PLUGIN_RESTARTABLE