diff --git a/plugins/libplugin.c b/plugins/libplugin.c index 87bafe965..d9182c281 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -617,6 +617,16 @@ bool rpc_scan_datastore_hex(struct plugin *plugin, return ret; } +static struct command_result *datastore_fail(struct command *command, + const char *buf, + const jsmntok_t *result, + void *unused) +{ + plugin_err(command->plugin, "datastore failed: %.*s", + json_tok_full_len(result), + json_tok_full(buf, result)); +} + struct command_result *jsonrpc_set_datastore_(struct plugin *plugin, struct command *cmd, const char *path, @@ -635,6 +645,11 @@ struct command_result *jsonrpc_set_datastore_(struct plugin *plugin, { struct out_req *req; + if (!cb) + cb = ignore_cb; + if (!errcb) + errcb = datastore_fail; + req = jsonrpc_request_start(plugin, cmd, "datastore", cb, errcb, arg); json_add_keypath(req->js->jout, "key", path); diff --git a/plugins/libplugin.h b/plugins/libplugin.h index d0e9336f5..c90a680c7 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -161,7 +161,9 @@ struct json_stream *jsonrpc_stream_fail_data(struct command *cmd, int code, const char *err); -/* Helper to jsonrpc_request_start() and send_outreq() to update datastore. */ +/* Helper to jsonrpc_request_start() and send_outreq() to update datastore. + * NULL cb means ignore, NULL errcb means plugin_error. +*/ struct command_result *jsonrpc_set_datastore_(struct plugin *plugin, struct command *cmd, const char *path,