diff --git a/lightningd/plugin.c b/lightningd/plugin.c index a158720ba..2e006d5b4 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1701,7 +1701,7 @@ static void plugin_set_timeout(struct plugin *p) } } -const char *plugin_send_getmanifest(struct plugin *p) +const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id) { char **cmd; int stdinfd, stdoutfd; @@ -1730,8 +1730,7 @@ const char *plugin_send_getmanifest(struct plugin *p) * write-only on p->stdin */ p->stdout_conn = io_new_conn(p, stdoutfd, plugin_stdout_conn_init, p); p->stdin_conn = io_new_conn(p, stdinfd, plugin_stdin_conn_init, p); - /* FIXME: id_prefix from caller! */ - req = jsonrpc_request_start(p, "getmanifest", NULL, p->log, + req = jsonrpc_request_start(p, "getmanifest", cmd_id, p->log, NULL, plugin_manifest_cb, p); json_add_bool(req->stream, "allow-deprecated-apis", deprecated_apis); jsonrpc_request_end(req); @@ -1742,7 +1741,7 @@ const char *plugin_send_getmanifest(struct plugin *p) return NULL; } -bool plugins_send_getmanifest(struct plugins *plugins) +bool plugins_send_getmanifest(struct plugins *plugins, const char *cmd_id) { struct plugin *p, *next; bool sent = false; @@ -1753,7 +1752,7 @@ bool plugins_send_getmanifest(struct plugins *plugins) if (p->plugin_state != UNCONFIGURED) continue; - err = plugin_send_getmanifest(p); + err = plugin_send_getmanifest(p, cmd_id); if (!err) { sent = true; continue; @@ -1795,7 +1794,7 @@ void plugins_init(struct plugins *plugins) setenv("LIGHTNINGD_PLUGIN", "1", 1); setenv("LIGHTNINGD_VERSION", version(), 1); - if (plugins_send_getmanifest(plugins)) { + if (plugins_send_getmanifest(plugins, NULL)) { void *ret; ret = io_loop_with_timers(plugins->ld); log_debug(plugins->ld->log, "io_loop_with_timers: %s", __func__); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 4b33b736e..fbcfbf486 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -214,17 +214,19 @@ bool plugin_blacklisted(struct plugins *plugins, const char *name); /** * Kick off initialization of a plugin. + * @p: plugin + * @cmd_id: optional JSON cmd_id which caused this. * * Returns error string, or NULL. */ -const char *plugin_send_getmanifest(struct plugin *p); +const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id); /** * Kick of initialization of all plugins which need it/ * * Return true if any were started. */ -bool plugins_send_getmanifest(struct plugins *plugins); +bool plugins_send_getmanifest(struct plugins *plugins, const char *cmd_id); /** * Kill a plugin process and free @plugin, with an error message. diff --git a/lightningd/plugin_control.c b/lightningd/plugin_control.c index 743584438..1d334a4cf 100644 --- a/lightningd/plugin_control.c +++ b/lightningd/plugin_control.c @@ -75,7 +75,7 @@ plugin_dynamic_start(struct plugin_command *pcmd, const char *plugin_path, errno ? strerror(errno) : "already registered"); /* This will come back via plugin_cmd_killed or plugin_cmd_succeeded */ - err = plugin_send_getmanifest(p); + err = plugin_send_getmanifest(p, pcmd->cmd->id); if (err) return command_fail(pcmd->cmd, PLUGIN_ERROR, "%s: %s", @@ -103,7 +103,7 @@ plugin_dynamic_startdir(struct plugin_command *pcmd, const char *dir_path) if (res) return res; - plugins_send_getmanifest(pcmd->cmd->ld->plugins); + plugins_send_getmanifest(pcmd->cmd->ld->plugins, pcmd->cmd->id); return command_still_pending(pcmd->cmd); } @@ -194,7 +194,7 @@ plugin_dynamic_rescan_plugins(struct plugin_command *pcmd) if (res) return res; - plugins_send_getmanifest(pcmd->cmd->ld->plugins); + plugins_send_getmanifest(pcmd->cmd->ld->plugins, pcmd->cmd->id); return command_still_pending(pcmd->cmd); } diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 75dd78e12..24b428e10 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -1486,6 +1486,9 @@ def test_libplugin(node_factory): l1.rpc.plugin_start(plugin) l1.rpc.check("helloworld") + # Side note: getmanifest will trace back to plugin_start + l1.daemon.wait_for_log(": OUT:id=[0-9]*/cln:getmanifest#[0-9]*") + # Test commands assert l1.rpc.call("helloworld") == {"hello": "world"} assert l1.rpc.call("helloworld", {"name": "test"}) == {"hello": "test"}