From 151bc475834b4dc6ea573bfe940c96b9f89f66c9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 6 Aug 2020 09:57:48 +0930 Subject: [PATCH] JSON-RPC: getmanifest passes allow-deprecated-apis flag. This allows plugins to choose how to present things in getmanifest. Signed-off-by: Rusty Russell Changelog-Added: plugins: `getmanifest` may now include "allow-deprecated-apis" boolean flag. Changelog-Deprecated: plugins: `getmanifest` without any parameters; plugins should accept any parameters for future use. --- contrib/plugins/fail/failtimeout.py | 2 +- doc/PLUGINS.md | 7 ++++--- lightningd/plugin.c | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/plugins/fail/failtimeout.py b/contrib/plugins/fail/failtimeout.py index 328bcff09..e5371cb52 100755 --- a/contrib/plugins/fail/failtimeout.py +++ b/contrib/plugins/fail/failtimeout.py @@ -8,7 +8,7 @@ import sys import time -def json_getmanifest(request): +def json_getmanifest(request, **kwargs): # Timeout is 60 seconds, so wait more time.sleep(61) return { diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index f41e5f26f..9c80101ba 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -57,9 +57,10 @@ interface. ### The `getmanifest` method -The `getmanifest` method is required for all plugins and will be called on -startup without any params. It MUST return a JSON object similar to -this example: +The `getmanifest` method is required for all plugins and will be +called on startup with optionsl parameters (in particular, it may have +`allow-deprecated-apis: false`, but you should accept others). It +MUST return a JSON object similar to this example: ```json { diff --git a/lightningd/plugin.c b/lightningd/plugin.c index d117b7cef..7b8ae9225 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1285,6 +1285,9 @@ const char *plugin_send_getmanifest(struct plugin *p) p->stdin_conn = io_new_conn(p, stdin, plugin_stdin_conn_init, p); req = jsonrpc_request_start(p, "getmanifest", p->log, plugin_manifest_cb, p); + /* Adding allow-deprecated-apis is part of the deprecation cycle! */ + if (!deprecated_apis) + json_add_bool(req->stream, "allow-deprecated-apis", deprecated_apis); jsonrpc_request_end(req); plugin_request_send(p, req); p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;