keysend: Allow quoted numbers in extratlvs

This is because JSON technically does not allow numeric keys in maps.

Changelog-Added: JSON-RPC: The `extratlvs` argument for `keysend` now allows quoting the type numbers in string
This commit is contained in:
Christian Decker
2022-10-25 14:47:56 +02:00
parent 83beaa5396
commit 8a4f44a58d
2 changed files with 7 additions and 2 deletions

View File

@@ -883,7 +883,11 @@ struct command_result *param_extra_tlvs(struct command *cmd, const char *name,
temp = tal_arr(cmd, struct tlv_field, tok->size);
json_for_each_obj(i, curr, tok) {
f = &temp[i];
if (!json_to_u64(buffer, curr, &f->numtype)) {
/* Accept either bare ints as keys (not spec
* compliant, but simpler), or ints in strings, which
* are JSON spec compliant. */
if (!(json_str_to_u64(buffer, curr, &f->numtype) ||
json_to_u64(buffer, curr, &f->numtype))) {
return command_fail(
cmd, JSONRPC2_INVALID_PARAMS,
"\"%s\" is not a valid numeric TLV type.",