diff --git a/plugins/autoclean.c b/plugins/autoclean.c index 57dba720c..01ef4257c 100644 --- a/plugins/autoclean.c +++ b/plugins/autoclean.c @@ -88,7 +88,7 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), + plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands, ARRAY_SIZE(commands), NULL, 0, NULL, 0, plugin_option("autocleaninvoice-cycle", "string", diff --git a/plugins/bcli.c b/plugins/bcli.c index 10874f2c7..215408ebe 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -947,7 +947,7 @@ int main(int argc, char *argv[]) bitcoind->rpcport = NULL; bitcoind->max_fee_multiplier = 10; - plugin_main(argv, init, PLUGIN_STATIC, commands, ARRAY_SIZE(commands), + plugin_main(argv, init, PLUGIN_STATIC, NULL, commands, ARRAY_SIZE(commands), NULL, 0, NULL, 0, plugin_option("bitcoin-datadir", "string", diff --git a/plugins/fundchannel.c b/plugins/fundchannel.c index 324c0e316..7caf70388 100644 --- a/plugins/fundchannel.c +++ b/plugins/fundchannel.c @@ -446,6 +446,6 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), - NULL, 0, NULL, 0, NULL); + plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands, + ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL); } diff --git a/plugins/keysend.c b/plugins/keysend.c index e13052fbc..40bc6ba35 100644 --- a/plugins/keysend.c +++ b/plugins/keysend.c @@ -131,4 +131,7 @@ int main(int argc, char *argv[]) setup_locale(); plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks), NULL); + plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands, + ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks), + NULL); } diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 20c2b8b9b..68c967d6b 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -86,7 +85,6 @@ struct plugin { struct feature_set *our_features; }; - /* command_result is mainly used as a compile-time check to encourage you * to return as soon as you get one (and not risk use-after-free of command). * Here we use two values: complete (cmd freed) and pending (still going) */ @@ -605,6 +603,18 @@ handle_getmanifest(struct command *getmanifest_cmd) json_add_string(params, NULL, p->hook_subs[i].name); json_array_end(params); + if (p->our_features != NULL) { + json_object_start(params, "features"); + for (size_t i = 0; i < NUM_FEATURE_PLACE; i++) { + u8 *f = p->our_features->bits[i]; + const char *fieldname = feature_place_names[i]; + if (fieldname == NULL) + continue; + json_add_hex(params, fieldname, f, tal_bytelen(f)); + } + json_object_end(params); + } + json_add_bool(params, "dynamic", p->restartability == PLUGIN_RESTARTABLE); return command_finished(getmanifest_cmd, params); @@ -1151,6 +1161,7 @@ static struct plugin *new_plugin(const tal_t *ctx, void (*init)(struct plugin *p, const char *buf, const jsmntok_t *), const enum plugin_restartability restartability, + struct feature_set *features, const struct plugin_command *commands, size_t num_commands, const struct plugin_notification *notif_subs, @@ -1173,6 +1184,8 @@ static struct plugin *new_plugin(const tal_t *ctx, p->rpc_len_read = 0; p->next_outreq_id = 0; uintmap_init(&p->out_reqs); + + p->our_features = features; /* Sync RPC FIXME: maybe go full async ? */ p->rpc_conn = tal(p, struct rpc_conn); membuf_init(&p->rpc_conn->mb, @@ -1210,6 +1223,7 @@ void plugin_main(char *argv[], void (*init)(struct plugin *p, const char *buf, const jsmntok_t *), const enum plugin_restartability restartability, + struct feature_set *features, const struct plugin_command *commands, size_t num_commands, const struct plugin_notification *notif_subs, @@ -1229,8 +1243,8 @@ void plugin_main(char *argv[], daemon_setup(argv[0], NULL, NULL); va_start(ap, num_hook_subs); - plugin = new_plugin(NULL, init, restartability, commands, num_commands, - notif_subs, num_notif_subs, hook_subs, + plugin = new_plugin(NULL, init, restartability, features, commands, + num_commands, notif_subs, num_notif_subs, hook_subs, num_hook_subs, ap); va_end(ap); setup_command_usage(plugin); diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 37deff2db..939122cce 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -245,6 +246,7 @@ void NORETURN LAST_ARG_NULL plugin_main(char *argv[], void (*init)(struct plugin *p, const char *buf, const jsmntok_t *), const enum plugin_restartability restartability, + struct feature_set *features, const struct plugin_command *commands, size_t num_commands, const struct plugin_notification *notif_subs, diff --git a/plugins/pay.c b/plugins/pay.c index deee3ec8b..338ee9ac1 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1712,6 +1712,6 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), - NULL, 0, NULL, 0, NULL); + plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands, + ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL); } diff --git a/tests/plugins/test_libplugin.c b/tests/plugins/test_libplugin.c index 2cc9c2a3a..7a6899ffa 100644 --- a/tests/plugins/test_libplugin.c +++ b/tests/plugins/test_libplugin.c @@ -123,7 +123,7 @@ static const struct plugin_notification notifs[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), + plugin_main(argv, init, PLUGIN_RESTARTABLE, NULL, commands, ARRAY_SIZE(commands), notifs, ARRAY_SIZE(notifs), hooks, ARRAY_SIZE(hooks), plugin_option("name", "string",