libplugin: jsonrpc_request_whole_object_start() for more custom request handling.

commando wants to see the whole reply object, and also not to assume params is
an object.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-07-16 14:30:17 +09:30
parent d0a55a62b3
commit d3e64c3970
2 changed files with 33 additions and 7 deletions

View File

@@ -117,6 +117,8 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin,
void *arg),
void *arg);
/* This variant has callbacks received whole obj, not "result" or
* "error" members. */
#define jsonrpc_request_start(plugin, cmd, method, cb, errcb, arg) \
jsonrpc_request_start_((plugin), (cmd), (method), \
typesafe_cb_preargs(struct command_result *, void *, \
@@ -132,6 +134,18 @@ struct out_req *jsonrpc_request_start_(struct plugin *plugin,
(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, cb, arg) \
jsonrpc_request_start_((plugin), (cmd), (method), \
typesafe_cb_preargs(struct command_result *, void *, \
(cb), (arg), \
struct command *command, \
const char *buf, \
const jsmntok_t *result), \
NULL, \
(arg))
/* Helper to create a JSONRPC2 response stream with a "result" object. */
struct json_stream *jsonrpc_stream_success(struct command *cmd);