From ebe5f2e68f6695af0c4b4afe00491e7a7712f27c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Nov 2025 12:07:13 +1030 Subject: [PATCH] libplugin: allow plugins to register optional filters for each hook they want. Signed-off-by: Rusty Russell --- plugins/libplugin.c | 13 +++++++++++++ plugins/libplugin.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/plugins/libplugin.c b/plugins/libplugin.c index db49590d6..8dfba2ce5 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -1302,6 +1302,19 @@ handle_getmanifest(struct command *getmanifest_cmd, p->hook_subs[i].after[j]); json_array_end(params); } + if (p->hook_subs[i].num_strfilters) { + json_array_start(params, "filters"); + for (size_t j = 0; j < p->hook_subs[i].num_strfilters; j++) + json_add_string(params, NULL, + p->hook_subs[i].strfilters[j]); + json_array_end(params); + } else if (p->hook_subs[i].num_intfilters) { + json_array_start(params, "filters"); + for (size_t j = 0; j < p->hook_subs[i].num_intfilters; j++) + json_add_u64(params, NULL, + p->hook_subs[i].intfilters[j]); + json_array_end(params); + } json_object_end(params); } json_array_end(params); diff --git a/plugins/libplugin.h b/plugins/libplugin.h index cec028b2f..bcc68dc03 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -99,6 +99,14 @@ struct plugin_hook { const jsmntok_t *params); /* If non-NULL, these are NULL-terminated arrays of deps */ const char **before, **after; + + /* String filters (you can only set this *or* intfilters) */ + const char **strfilters; + size_t num_strfilters; + + /* Integer filters */ + const u64 *intfilters; + size_t num_intfilters; }; /* Return the feature set of the current lightning node */