commando: require that we have an id field in JSON request.

We don't do this yet, so we add deprecated to those test (until next
patch!).

Changelog-Deprecated: plugins: `commando` JSON commands without an `id` (see doc/lightningd-rpc.7.md for how to construct a good id field).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-01-03 14:53:28 +10:30
parent 435f8d84dc
commit 19db6a25e4
2 changed files with 11 additions and 5 deletions

View File

@@ -362,7 +362,7 @@ static void try_command(struct node_id *peer,
const u8 *msg, size_t msglen)
{
struct commando *incoming = tal(plugin, struct commando);
const jsmntok_t *toks, *method, *params, *rune;
const jsmntok_t *toks, *method, *params, *rune, *id;
const char *buf = (const char *)msg, *failmsg;
struct out_req *req;
@@ -394,6 +394,12 @@ static void try_command(struct node_id *peer,
return;
}
rune = json_get_member(buf, toks, "rune");
id = json_get_member(buf, toks, "id");
if (!id && !deprecated_apis) {
commando_error(incoming, COMMANDO_ERROR_REMOTE,
"missing id field");
return;
}
failmsg = check_rune(tmpctx, incoming, peer, buf, method, params, rune);
if (failmsg) {