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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-11-17 16:20:06 +10:30
parent 41e15b1ac9
commit c93153ec37
2 changed files with 11 additions and 0 deletions

View File

@ -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)) {

View File

@ -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"}, {}])