From c7531b0f8f5fc14a46cd05525f8cb9b3bdebeb5d Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Wed, 1 Oct 2025 11:26:56 +0200 Subject: [PATCH] plugin: remove features when plugin is disabled We need to remove the feature bits set via a plugins get_manifest response when the init response disables the plugin. Changelog-Fixed Remove feature bits set by a plugin when the plugin disables itself during init. Signed-off-by: Peter Neuroth --- lightningd/plugin.c | 9 +++++++++ lightningd/plugin.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 1dba9a94d..5d031e73a 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1819,6 +1819,11 @@ static const char *plugin_parse_getmanifest_response(const char *buffer, return tal_fmt(plugin, "Custom featurebits already present"); } + + /* Store fset to allow to remove feature bits when init returns disabled */ + plugin->fset = tal_dup_or_null(plugin, struct feature_set, fset); + } else { + plugin->fset = NULL; } custommsgtok = json_get_member(buffer, resulttok, "custommessages"); @@ -2148,6 +2153,10 @@ static void plugin_config_cb(const char *buffer, JSON_SCAN_TAL(tmpctx, json_strdup, &disable)) == NULL) { /* Don't get upset if this was a built-in! */ plugin->important = false; + if (plugin->fset) + /* We don't have those features anymore! */ + feature_set_sub(plugin->plugins->ld->our_features, + plugin->fset); plugin_kill(plugin, LOG_DBG, "disabled itself at init: %s", disable); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 621f3b8d7..3481d3565 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -120,6 +120,9 @@ struct plugin { /* Can this handle check commands? */ bool can_check; + + /* custom feature-bits */ + struct feature_set *fset; }; /**