From c93153ec375de8a09817f55536dd56a3f40771f9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 17 Nov 2024 16:20:06 +1030 Subject: [PATCH] lightningd: allow builtin plugins to be stopped. These are automatically marked "important", in the sense that we won't startup if they are not working, but this wasn't meant to disallow stopping them. Changelog-Changed: JSON-RPC: built-in plugins can now be stopped using "plugin stop". Signed-off-by: Rusty Russell --- lightningd/plugin_control.c | 2 ++ tests/test_plugin.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lightningd/plugin_control.c b/lightningd/plugin_control.c index b4f6ec1a0..2f8bb4ed0 100644 --- a/lightningd/plugin_control.c +++ b/lightningd/plugin_control.c @@ -156,6 +156,8 @@ plugin_dynamic_stop(struct command *cmd, const char *plugin_name) "%s cannot be managed when " "lightningd is up", plugin_name); + /* Don't freak out, even if it's a built-in */ + p->important = false; /* If it's interested in clean shutdown, tell it. */ if (notify_plugin_shutdown(cmd->ld, p)) { diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 725a2d638..4a893cdc6 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -4450,6 +4450,15 @@ def test_listchannels_broken_message(node_factory): l1.rpc.listchannels() +def test_important_plugin_shutdown(node_factory): + """We can shutdown an important plugin (as long as it's dynamic) without dying""" + + l1 = node_factory.get_node() + + l1.rpc.plugin_stop("pay") + l1.rpc.plugin_start(os.path.join(os.getcwd(), 'plugins/pay')) + + @unittest.skipIf(VALGRIND, "It does not play well with prompt and key derivation.") def test_exposesecret(node_factory): l1, l2 = node_factory.get_nodes(2, opts=[{'exposesecret-passphrase': "test_exposesecret"}, {}])