From c71f4f3bd940af59c00e639874916182085c8ecd Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 20 Sep 2018 20:43:55 +0200 Subject: [PATCH] plugin: Add listconfigs stub for the --plugin option --- lightningd/options.c | 2 +- lightningd/plugin.c | 15 +++++++++++++++ lightningd/plugin.h | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lightningd/options.c b/lightningd/options.c index 22ecdd4bc..d7962059a 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -971,7 +971,7 @@ static void add_config(struct lightningd *ld, if (ld->proxyaddr) answer = fmt_wireaddr(name0, ld->proxyaddr); } else if (opt->cb_arg == (void *)opt_add_plugin) { - /* FIXME: Actually add the plugin options */ + json_add_opt_plugins(response, ld->plugins); #if DEVELOPER } else if (strstarts(name, "dev-")) { /* Ignore dev settings */ diff --git a/lightningd/plugin.c b/lightningd/plugin.c index f7c8f95f2..9ec6d1b77 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -2,6 +2,8 @@ #include #include +#include +#include struct plugin { int stdin, stdout; @@ -33,3 +35,16 @@ void plugin_register(struct plugins *plugins, const char* path TAKES) void plugins_init(struct plugins *plugins) { } + +void json_add_opt_plugins(struct json_stream *response, + const struct plugins *plugins) +{ + struct plugin *p; + json_object_start(response, "plugin"); + for (size_t i=0; iplugins); i++) { + p = plugins->plugins[i]; + json_object_start(response, p->cmd); + json_object_end(response); + } + json_object_end(response); +} diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 60bf3da67..57d79d158 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -3,6 +3,7 @@ #include "config.h" #include #include +#include /** * A collection of plugins, and some associated information. @@ -35,4 +36,13 @@ void plugins_init(struct plugins *plugins); */ void plugin_register(struct plugins *plugins, const char* path TAKES); +/** + * Add the plugin option and their respective options to listconfigs. + * + * This adds a dict that maps the plugin name to a dict of configuration options + * for the corresponding plugins. + */ +void json_add_opt_plugins(struct json_stream *response, + const struct plugins *plugins); + #endif /* LIGHTNING_LIGHTNINGD_PLUGIN_H */