common/json_stream: make json_add_jsonstr take a length.

This is useful when have have a jsmntok_t.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-07-16 14:28:58 +09:30
parent f65d3bb1fc
commit d0a55a62b3
6 changed files with 23 additions and 15 deletions

View File

@@ -499,7 +499,8 @@ multifundchannel_finished(struct multifundchannel_command *mfc)
mfc->removeds[i].error_message);
if (mfc->removeds[i].error_data)
json_add_jsonstr(out, "data",
mfc->removeds[i].error_data);
mfc->removeds[i].error_data,
strlen(mfc->removeds[i].error_data));
json_object_end(out); /* End error object */
json_object_end(out);
}
@@ -1382,7 +1383,8 @@ perform_fundpsbt(struct multifundchannel_command *mfc, u32 feerate)
&after_fundpsbt,
&mfc_forward_error,
mfc);
json_add_jsonstr(req->js, "utxos", mfc->utxos_str);
json_add_jsonstr(req->js, "utxos",
mfc->utxos_str, strlen(mfc->utxos_str));
json_add_bool(req->js, "reservedok", false);
} else {
plugin_log(mfc->cmd->plugin, LOG_DBG,
@@ -1814,7 +1816,8 @@ post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo)
json_add_string(out, "method", failing_method);
if (mfc->removeds[i].error_data)
json_add_jsonstr(out, "data",
mfc->removeds[i].error_data);
mfc->removeds[i].error_data,
strlen(mfc->removeds[i].error_data));
/* Close 'data'. */
json_object_end(out);

View File

@@ -356,7 +356,7 @@ static struct command_result *start_mw(struct multiwithdraw_command *mw)
&mw_forward_error,
mw);
json_add_bool(req->js, "reservedok", false);
json_add_jsonstr(req->js, "utxos", mw->utxos);
json_add_jsonstr(req->js, "utxos", mw->utxos, strlen(mw->utxos));
} else {
plugin_log(mw->cmd->plugin, LOG_DBG,
"multiwithdraw %"PRIu64": fundpsbt.",

View File

@@ -346,7 +346,9 @@ openchannel_finished(struct multifundchannel_command *mfc)
json_add_node_id(out, "id", &dest->id);
json_add_string(out, "method", "openchannel_signed");
if (dest->error_data)
json_add_jsonstr(out, "data", dest->error_data);
json_add_jsonstr(out, "data",
dest->error_data,
strlen(dest->error_data));
json_object_end(out);
return mfc_finished(mfc, out);