From 8b2a84a0c7b5bc751d674733e4d8fd71416eafa5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 May 2019 20:37:57 +0930 Subject: [PATCH] plugins: don't hand empty strings for unset options. This was deeply surprising to me; there's a difference between a value not being specified, and it being specified as "". Signed-off-by: Rusty Russell --- doc/PLUGINS.md | 2 +- lightningd/plugin.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index 21792f3e2..33c959feb 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -40,7 +40,7 @@ methods are required: - `getmanifest` asks the plugin for command line options and JSON-RPC commands that should be passed through - `init` is called after the command line options have been - parsed and passes them through with the real values. This is also + parsed and passes them through with the real values (if specified). This is also the signal that `lightningd`'s JSON-RPC over Unix Socket is now up and ready to receive incoming requests from the plugin. diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 27e63f10a..a1d32b60d 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1000,9 +1000,8 @@ static void plugin_config(struct plugin *plugin) list_for_each(&plugin->plugin_opts, opt, list) { /* Trim the `--` that we added before */ name = opt->name + 2; - if (!opt->value) - opt->value = ""; - json_add_string(req->stream, name, opt->value); + if (opt->value) + json_add_string(req->stream, name, opt->value); } json_object_end(req->stream); /* end of .params.options */