diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c index 1fb660a3f..11091edd9 100644 --- a/plugins/chanbackup.c +++ b/plugins/chanbackup.c @@ -665,7 +665,7 @@ static struct command_result *commit_peer_backup(struct command *cmd, "chanbackup/peers/%s", fmt_node_id(tmpctx, &pb->peer)), - pb->data, + pb->data, tal_bytelen(pb->data), "create-or-replace", NULL, NULL, NULL); } @@ -899,6 +899,7 @@ static struct command_result *handle_your_peer_storage(struct command *cmd, return jsonrpc_set_datastore_binary(cmd, "chanbackup/latestscb", decoded_bkp, + tal_bytelen(decoded_bkp), "create-or-replace", datastore_success, datastore_failed, diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 896564f70..614b5d3db 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -912,7 +912,7 @@ void rpc_enable_batching(struct plugin *plugin) struct command_result *jsonrpc_set_datastore_(struct command *cmd, const char *path, const void *value, - bool value_is_string, + int len_or_str, const char *mode, struct command_result *(*cb)(struct command *command, const char *method, @@ -936,10 +936,10 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd, req = jsonrpc_request_start(cmd, "datastore", cb, errcb, arg); json_add_keypath(req->js->jout, "key", path); - if (value_is_string) + if (len_or_str == -1) json_add_string(req->js, "string", value); else - json_add_hex_talarr(req->js, "hex", value); + json_add_hex(req->js, "hex", value, len_or_str); json_add_string(req->js, "mode", mode); return send_outreq(req); } diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 54b4f883f..2cc781da8 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -272,7 +272,7 @@ struct json_stream *jsonrpc_stream_fail_data(struct command *cmd, struct command_result *jsonrpc_set_datastore_(struct command *cmd, const char *path, const void *value, - bool value_is_string, + int len_or_str, const char *mode, struct command_result *(*cb)(struct command *command, const char *method, @@ -288,7 +288,7 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd, NON_NULL_ARGS(1, 2, 3, 5); #define jsonrpc_set_datastore_string(cmd, path, str, mode, cb, errcb, arg) \ - jsonrpc_set_datastore_((cmd), (path), (str), true, (mode), \ + jsonrpc_set_datastore_((cmd), (path), (str), -1, (mode), \ typesafe_cb_preargs(struct command_result *, void *, \ (cb), (arg), \ struct command *command, \ @@ -303,8 +303,8 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd, const jsmntok_t *result), \ (arg)) -#define jsonrpc_set_datastore_binary(cmd, path, tal_ptr, mode, cb, errcb, arg) \ - jsonrpc_set_datastore_((cmd), (path), (tal_ptr), false, (mode), \ +#define jsonrpc_set_datastore_binary(cmd, path, ptr, len, mode, cb, errcb, arg) \ + jsonrpc_set_datastore_((cmd), (path), (ptr), (len), (mode), \ typesafe_cb_preargs(struct command_result *, void *, \ (cb), (arg), \ struct command *command, \