diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 9504c302c5ea..bf41f42c720b 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -611,8 +611,21 @@ struct rpc_command_hook_payload { static void rpc_command_hook_serialize(struct rpc_command_hook_payload *p, struct json_stream *s) { + const jsmntok_t *tok; + size_t i; + char *key; json_object_start(s, "rpc_command"); + +#ifdef COMPAT_V081 json_add_tok(s, "rpc_command", p->request, p->buffer); +#endif + + json_for_each_obj(i, tok, p->request) { + key = tal_strndup(NULL, p->buffer + tok->start, + tok->end - tok->start); + json_add_tok(s, key, tok + 1, p->buffer); + tal_free(key); + } json_object_end(s); } diff --git a/tests/plugins/rpc_command.py b/tests/plugins/rpc_command.py index 5ff12b08ce5d..3d951246ef27 100755 --- a/tests/plugins/rpc_command.py +++ b/tests/plugins/rpc_command.py @@ -9,7 +9,7 @@ @plugin.hook("rpc_command") def on_rpc_command(plugin, rpc_command, **kwargs): - request = rpc_command["rpc_command"] + request = rpc_command if request["method"] == "invoice": # Replace part of this command request["params"]["description"] = "A plugin modified this description"