diff --git a/common/features.c b/common/features.c index 9989cb93a..490cb18a9 100644 --- a/common/features.c +++ b/common/features.c @@ -19,6 +19,14 @@ struct feature_style { enum feature_copy_style copy_style[NUM_FEATURE_PLACE]; }; +const char *feature_place_names[] = { + "init", + NULL, + "node", + "channel", + "invoice" +}; + static const struct feature_style feature_styles[] = { { OPT_DATA_LOSS_PROTECT, .copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT, diff --git a/common/features.h b/common/features.h index cf364d8c8..dd844bb4b 100644 --- a/common/features.h +++ b/common/features.h @@ -13,6 +13,8 @@ enum feature_place { }; #define NUM_FEATURE_PLACE (BOLT11_FEATURE+1) +extern const char *feature_place_names[NUM_FEATURE_PLACE]; + /* The complete set of features for all contexts */ struct feature_set { u8 *bits[NUM_FEATURE_PLACE]; diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 97bc6c184..01e5e4d67 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -896,9 +896,6 @@ static void plugin_manifest_timeout(struct plugin *plugin) fatal("Can't recover from plugin failure, terminating."); } -/* List of JSON keys matching `enum feature_place`. */ -static const char *plugin_feature_place_names[] = {"init", NULL, "node", "channel", "invoice"}; - bool plugin_parse_getmanifest_response(const char *buffer, const jsmntok_t *toks, const jsmntok_t *idtok, @@ -922,16 +919,16 @@ bool plugin_parse_getmanifest_response(const char *buffer, bool have_featurebits = false; struct feature_set *fset = talz(tmpctx, struct feature_set); - BUILD_ASSERT(ARRAY_SIZE(plugin_feature_place_names) + BUILD_ASSERT(ARRAY_SIZE(feature_place_names) == ARRAY_SIZE(fset->bits)); for (int i = 0; i < ARRAY_SIZE(fset->bits); i++) { /* We don't allow setting the obs global init */ - if (!plugin_feature_place_names[i]) + if (!feature_place_names[i]) continue; tok = json_get_member(buffer, featurestok, - plugin_feature_place_names[i]); + feature_place_names[i]); if (!tok) continue; @@ -1214,9 +1211,9 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req) json_add_string(req->stream, "network", chainparams->network_name); json_object_start(req->stream, "feature_set"); for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) { - if (plugin_feature_place_names[fp]) { + if (feature_place_names[fp]) { json_add_hex_talarr(req->stream, - plugin_feature_place_names[fp], + feature_place_names[fp], ld->our_features->bits[fp]); } }