diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 6687fe838..f3c70d03e 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -325,6 +325,7 @@ struct out_req * jsonrpc_request_start_(struct plugin *plugin, struct command *cmd, const char *method, const char *id_prefix, + const char *filter, struct command_result *(*cb)(struct command *command, const char *buf, const jsmntok_t *result, @@ -355,6 +356,12 @@ jsonrpc_request_start_(struct plugin *plugin, struct command *cmd, json_add_string(out->js, "jsonrpc", "2.0"); json_add_id(out->js, out->id); json_add_string(out->js, "method", method); + if (filter) { + /* This is raw JSON, so paste, don't escape! */ + size_t len = strlen(filter); + char *p = json_out_member_direct(out->js->jout, "filter", len); + memcpy(p, filter, len); + } if (out->errcb) json_object_start(out->js, "params"); diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 331f45d26..07e959d3c 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -103,6 +103,7 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin, struct command *cmd, const char *method, const char *id_prefix, + const char *filter, struct command_result *(*cb)(struct command *command, const char *buf, const jsmntok_t *result, @@ -117,7 +118,7 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin, * "error" members. */ #define jsonrpc_request_start(plugin, cmd, method, cb, errcb, arg) \ jsonrpc_request_start_((plugin), (cmd), (method), \ - json_id_prefix(tmpctx, (cmd)), \ + json_id_prefix(tmpctx, (cmd)), NULL, \ typesafe_cb_preargs(struct command_result *, void *, \ (cb), (arg), \ struct command *command, \ @@ -130,11 +131,25 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin, const jsmntok_t *result), \ (arg)) +#define jsonrpc_request_with_filter_start(plugin, cmd, method, filter, cb, errcb, arg) \ + jsonrpc_request_start_((plugin), (cmd), (method), \ + json_id_prefix(tmpctx, (cmd)), (filter), \ + typesafe_cb_preargs(struct command_result *, void *, \ + (cb), (arg), \ + struct command *command, \ + const char *buf, \ + const jsmntok_t *result), \ + typesafe_cb_preargs(struct command_result *, void *, \ + (errcb), (arg), \ + struct command *command, \ + const char *buf, \ + const jsmntok_t *result), \ + (arg)) /* This variant has callbacks received whole obj, not "result" or * "error" members. It also doesn't start params{}. */ #define jsonrpc_request_whole_object_start(plugin, cmd, method, id_prefix, cb, arg) \ - jsonrpc_request_start_((plugin), (cmd), (method), (id_prefix), \ + jsonrpc_request_start_((plugin), (cmd), (method), (id_prefix), NULL, \ typesafe_cb_preargs(struct command_result *, void *, \ (cb), (arg), \ struct command *command, \ diff --git a/plugins/test/run-route-calc.c b/plugins/test/run-route-calc.c index 5cee7ad8e..ee4a1ab74 100644 --- a/plugins/test/run-route-calc.c +++ b/plugins/test/run-route-calc.c @@ -228,6 +228,7 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin UNNEEDED, struct command *cmd UNNEEDED, const char *method UNNEEDED, const char *id_prefix UNNEEDED, + const char *filter UNNEEDED, struct command_result *(*cb)(struct command *command UNNEEDED, const char *buf UNNEEDED, const jsmntok_t *result UNNEEDED, diff --git a/plugins/test/run-route-overlong.c b/plugins/test/run-route-overlong.c index 3e55dc4cb..8f9ce9bde 100644 --- a/plugins/test/run-route-overlong.c +++ b/plugins/test/run-route-overlong.c @@ -225,6 +225,7 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin UNNEEDED, struct command *cmd UNNEEDED, const char *method UNNEEDED, const char *id_prefix UNNEEDED, + const char *filter UNNEEDED, struct command_result *(*cb)(struct command *command UNNEEDED, const char *buf UNNEEDED, const jsmntok_t *result UNNEEDED,