commando: added check for empty params

Changelog-Changed: Protocol: commando commands now allow a missing params field, instead of requiring an empty field.

No-schema-diff-check
This commit is contained in:
Shahana Farooqui
2023-07-14 22:51:46 -07:00
committed by Rusty Russell
parent a4835cf266
commit 93a3d7f632

View File

@@ -395,7 +395,7 @@ static const char *check_condition(const tal_t *ctx,
} }
/* Rest are params looksup: generate this once! */ /* Rest are params looksup: generate this once! */
if (strmap_empty(&cinfo->cached_params)) { if (strmap_empty(&cinfo->cached_params) && cinfo->params) {
const jsmntok_t *t; const jsmntok_t *t;
size_t i; size_t i;
@@ -518,7 +518,7 @@ static void try_command(struct node_id *peer,
return; return;
} }
params = json_get_member(buf, toks, "params"); params = json_get_member(buf, toks, "params");
if (!params || (params->type != JSMN_OBJECT && params->type != JSMN_ARRAY)) { if (params && (params->type != JSMN_OBJECT && params->type != JSMN_ARRAY)) {
commando_error(incoming, COMMANDO_ERROR_REMOTE, commando_error(incoming, COMMANDO_ERROR_REMOTE,
"Params must be object or array"); "Params must be object or array");
return; return;