diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 1dba9a94dd87..5d031e73af9a 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 621f3b8d747d..3481d35655b1 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; }; /**