libplugin: don't turn non-string JSON ids into strings.

When called with `"id": 1` we replied with `"id": "1"`.  lightningd doesn't
actually care, but it's weird.

Copy the entire token: this way we don't have to special case anything.

Also, remove the doubled test in json_add_jsonstr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-12-27 17:39:34 +10:30
parent 9ed138f5e5
commit 2d8fff6b57
5 changed files with 39 additions and 19 deletions

View File

@@ -239,9 +239,6 @@ void json_add_jsonstr(struct json_stream *js,
{
char *p;
if (!json_filter_ok(js->filter, fieldname))
return;
/* NOTE: Filtering doesn't really work here! */
if (!json_filter_ok(js->filter, fieldname))
return;
@@ -690,3 +687,11 @@ void json_add_lease_rates(struct json_stream *result,
rates->channel_fee_max_proportional_thousandths);
}
void json_add_id(struct json_stream *result, const char *id)
{
char *p;
/* Bypass escape-required assertion in json_out_add */
p = json_member_direct(result, "id", strlen(id));
memcpy(p, id, strlen(id));
}