plugins: simplify datastore interfaces now callers have mkdatastorekey.
What changed, and why it matters
This commit is a routine internal code cleanup. It replaces hand-built slash-separated datastore key strings with a new helper function, mkdatastorekey, that builds the same keys as a list of separate parts. There is no indication this fixes a security bug; it is a refactoring to make the code simpler and less error-prone.
No security action required. Treat as normal refactoring; review the companion mkdatastorekey implementation if desired to confirm it handles memory allocation correctly.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors Core Lightning plugin datastore helpers. Previously callers passed a single ‘/’-delimited string (e.g., ‘bookkeeper/account/
Changed components
plugins/libplugin.cplugins/libplugin.hplugins/autoclean.cplugins/bkpr/account.cplugins/bkpr/blockheights.cplugins/bkpr/bookkeeper.cplugins/bkpr/descriptions.cplugins/bkpr/onchain_fee.cplugins/bkpr/rebalances.cplugins/chanbackup.ctests/plugins/test_libplugin.ccommon/mkdatastorekey.h (referenced, not changed in this commit)Inspect captured patch +91 / −74
diff --git a/plugins/autoclean.c b/plugins/autoclean.c
index 4ac88da3..37923e0e 100644
--- a/plugins/autoclean.c
+++ b/plugins/autoclean.c
@@ -6,6 +6,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <inttypes.h>
#include <plugins/libplugin.h>
@@ -261,12 +262,11 @@ static u64 *total_cleaned(const struct subsystem_and_variant *sv)
return &totals[sv->type][sv->variant];
}
-static const char *datastore_path(const tal_t *ctx,
- const struct subsystem_and_variant *sv,
- const char *field)
+static const char **datastore_path(const tal_t *ctx,
+ const struct subsystem_and_variant *sv,
+ const char *field)
{
- return tal_fmt(ctx, "autoclean/%s/%s",
- subsystem_to_str(sv), field);
+ return mkdatastorekey(ctx, "autoclean", subsystem_to_str(sv), field);
}
static struct command_result *clean_finished(struct clean_info *cinfo)
diff --git a/plugins/bkpr/account.c b/plugins/bkpr/account.c
index 6ff4f01c..c8b07468 100644
--- a/plugins/bkpr/account.c
+++ b/plugins/bkpr/account.c
@@ -5,6 +5,7 @@
#include <ccan/str/str.h>
#include <ccan/tal/str/str.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/node_id.h>
#include <plugins/bkpr/account.h>
#include <plugins/bkpr/bookkeeper.h>
@@ -144,16 +145,16 @@ struct account **list_accounts(const tal_t *ctx, const struct bkpr *bkpr)
return results;
}
-static const char *ds_path(const tal_t *ctx, const char *acctname)
+static const char **ds_path(const tal_t *ctx, const char *acctname)
{
- return tal_fmt(ctx, "bookkeeper/account/%s", acctname);
+ return mkdatastorekey(ctx, "bookkeeper", "account", acctname);
}
static void account_datastore_set(struct command *cmd,
const struct account *acct,
const char *mode)
{
- const char *path = ds_path(tmpctx, acct->name);
+ const char **path = ds_path(tmpctx, acct->name);
u8 *data = tal_arr(tmpctx, u8, 0);
towire_account(&data, acct);
diff --git a/plugins/bkpr/blockheights.c b/plugins/bkpr/blockheights.c
index e483a066..35aa229e 100644
--- a/plugins/bkpr/blockheights.c
+++ b/plugins/bkpr/blockheights.c
@@ -6,6 +6,7 @@
#include <ccan/str/str.h>
#include <ccan/tal/str/str.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/utils.h>
#include <inttypes.h>
#include <plugins/bkpr/blockheights.h>
@@ -51,12 +52,13 @@ static void memleak_scan_blockheight_htable(struct htable *memtable,
memleak_scan_htable(memtable, &ht->raw);
}
-static const char *ds_blockheight_path(const tal_t *ctx,
- const struct bitcoin_txid *txid)
+static const char **ds_blockheight_path(const tal_t *ctx,
+ const struct bitcoin_txid *txid)
{
/* Keys like: bookkeeper/blockheights/<txid> */
- return tal_fmt(ctx, "bookkeeper/blockheights/%s",
- fmt_bitcoin_txid(tmpctx, txid));
+ return mkdatastorekey(ctx,
+ "bookkeeper", "blockheights",
+ take(fmt_bitcoin_txid(NULL, txid)));
}
void add_blockheight(struct command *cmd,
@@ -67,7 +69,7 @@ void add_blockheight(struct command *cmd,
struct blockheights *bh = bkpr->blockheights;
struct blockheight_entry *e;
be32 be_blockheight;
- const char *path = ds_blockheight_path(tmpctx, txid);
+ const char **path = ds_blockheight_path(tmpctx, txid);
/* Update in-memory map (replace or insert) */
e = blockheight_htable_get(bh->map, txid);
diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c
index 746c441a..06652c7d 100644
--- a/plugins/bkpr/bookkeeper.c
+++ b/plugins/bkpr/bookkeeper.c
@@ -14,6 +14,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/node_id.h>
#include <db/exec.h>
#include <errno.h>
@@ -161,7 +162,8 @@ static struct command_result *listchannelmoves_done(struct command *cmd,
parse_and_log_channel_move(cmd, buf, t, rinfo);
be_index = cpu_to_be64(bkpr->channelmoves_index);
- jsonrpc_set_datastore_binary(cmd, "bookkeeper/channelmoves_index",
+ jsonrpc_set_datastore_binary(cmd,
+ mkdatastorekey(tmpctx, "bookkeeper", "channelmoves_index"),
&be_index, sizeof(be_index),
"create-or-replace",
datastore_done, NULL, use_rinfo(rinfo));
@@ -206,7 +208,8 @@ static struct command_result *listchainmoves_done(struct command *cmd,
parse_and_log_chain_move(cmd, buf, t, rinfo);
be_index = cpu_to_be64(bkpr->chainmoves_index);
- jsonrpc_set_datastore_binary(cmd, "bookkeeper/chainmoves_index",
+ jsonrpc_set_datastore_binary(cmd,
+ mkdatastorekey(tmpctx, "bookkeeper", "chainmoves_index"),
&be_index, sizeof(be_index),
"create-or-replace",
datastore_done, NULL, use_rinfo(rinfo));
@@ -1753,12 +1756,14 @@ static const char *init(struct command *init_cmd, const char *b, const jsmntok_t
find_or_create_account(init_cmd, bkpr, ACCOUNT_NAME_WALLET);
/* Not existing is OK! */
- if (rpc_scan_datastore_hex(tmpctx, init_cmd, "bookkeeper/channelmoves_index",
+ if (rpc_scan_datastore_hex(tmpctx, init_cmd,
+ mkdatastorekey(tmpctx, "bookkeeper", "channelmoves_index"),
JSON_SCAN(json_hex_to_be64, &index)) == NULL) {
bkpr->channelmoves_index = be64_to_cpu(index);
} else
bkpr->channelmoves_index = 0;
- if (rpc_scan_datastore_hex(tmpctx, init_cmd, "bookkeeper/chainmoves_index",
+ if (rpc_scan_datastore_hex(tmpctx, init_cmd,
+ mkdatastorekey(tmpctx, "bookkeeper", "chainmoves_index"),
JSON_SCAN(json_hex_to_be64, &index)) == NULL) {
bkpr->chainmoves_index = be64_to_cpu(index);
} else
diff --git a/plugins/bkpr/descriptions.c b/plugins/bkpr/descriptions.c
index fd59dab5..d8b03cce 100644
--- a/plugins/bkpr/descriptions.c
+++ b/plugins/bkpr/descriptions.c
@@ -7,6 +7,7 @@
#include <ccan/tal/str/str.h>
#include <ccan/tal/tal.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/utils.h>
#include <plugins/bkpr/bookkeeper.h>
#include <plugins/bkpr/chain_event.h>
@@ -78,16 +79,16 @@ struct descriptions {
struct payment_hash_desc_htable *by_payment_hash;
};
-static const char *ds_desc_utxo_path(const tal_t *ctx,
- const struct bitcoin_outpoint *outp)
+static const char **ds_desc_utxo_path(const tal_t *ctx,
+ const struct bitcoin_outpoint *outp)
{
- return tal_fmt(ctx, "bookkeeper/description/utxo/%s", fmt_bitcoin_outpoint(tmpctx, outp));
+ return mkdatastorekey(ctx, "bookkeeper", "description", "utxo", take(fmt_bitcoin_outpoint(NULL, outp)));
}
static void utxo_desc_datastore_update(struct command *cmd,
const struct utxo_desc *utxo_desc)
{
- const char *path = ds_desc_utxo_path(tmpctx, &utxo_desc->outp);
+ const char **path = ds_desc_utxo_path(tmpctx, &utxo_desc->outp);
jsonrpc_set_datastore_binary(cmd, path,
utxo_desc->desc, strlen(utxo_desc->desc),
@@ -95,17 +96,17 @@ static void utxo_desc_datastore_update(struct command *cmd,
ignore_datastore_reply, NULL, NULL);
}
-static const char *ds_desc_payment_hash_path(const tal_t *ctx,
- const struct sha256 *payment_hash)
+static const char **ds_desc_payment_hash_path(const tal_t *ctx,
+ const struct sha256 *payment_hash)
{
- return tal_fmt(ctx, "bookkeeper/description/payment/%s",
- fmt_sha256(tmpctx, payment_hash));
+ return mkdatastorekey(ctx, "bookkeeper", "description", "payment",
+ take(fmt_sha256(NULL, payment_hash)));
}
static void payment_hash_desc_datastore_update(struct command *cmd,
const struct payment_hash_desc *phd)
{
- const char *path = ds_desc_payment_hash_path(tmpctx, &phd->payment_hash);
+ const char **path = ds_desc_payment_hash_path(tmpctx, &phd->payment_hash);
jsonrpc_set_datastore_binary(cmd, path, phd->desc, strlen(phd->desc),
"create-or-replace",
ignore_datastore_reply, NULL, NULL);
diff --git a/plugins/bkpr/onchain_fee.c b/plugins/bkpr/onchain_fee.c
index 02537150..79b6f15a 100644
--- a/plugins/bkpr/onchain_fee.c
+++ b/plugins/bkpr/onchain_fee.c
@@ -8,6 +8,7 @@
#include <ccan/tal/str/str.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/pseudorand.h>
#include <inttypes.h>
#include <plugins/bkpr/account.h>
@@ -173,15 +174,15 @@ static struct onchain_fee *fromwire_onchain_fee(struct onchain_fees *onchain_fee
update_count);
}
-static const char *ds_ofee_path(const tal_t *ctx, const char *acctname)
+static const char **ds_ofee_path(const tal_t *ctx, const char *acctname TAKES)
{
- return tal_fmt(ctx, "bookkeeper/onchain_fee/%s", acctname);
+ return mkdatastorekey(ctx, "bookkeeper", "onchain_fee", acctname);
}
static void onchain_fee_datastore_add(struct command *cmd,
const struct onchain_fee *of)
{
- const char *path = ds_ofee_path(tmpctx, of->acct_name);
+ const char **path = ds_ofee_path(tmpctx, of->acct_name);
u8 *data = tal_arr(tmpctx, u8, 0);
towire_onchain_fee(&data, of);
diff --git a/plugins/bkpr/rebalances.c b/plugins/bkpr/rebalances.c
index 91d9dd6f..ad918542 100644
--- a/plugins/bkpr/rebalances.c
+++ b/plugins/bkpr/rebalances.c
@@ -6,6 +6,7 @@
#include <ccan/tal/str/str.h>
#include <common/coin_mvt.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/node_id.h>
#include <common/utils.h>
#include <inttypes.h>
@@ -60,7 +61,7 @@ static void new_rebalance_pair(struct rebalances *r,
rebalance_htable_add(r->pairs, p2);
}
-static const char *ds_rebalance_path(const tal_t *ctx, u64 id1, u64 id2)
+static const char **ds_rebalance_path(const tal_t *ctx, u64 id1, u64 id2)
{
u64 lesser, greater;
if (id1 < id2) {
@@ -70,15 +71,16 @@ static const char *ds_rebalance_path(const tal_t *ctx, u64 id1, u64 id2)
lesser = id2;
greater = id1;
}
- return tal_fmt(ctx, "bookkeeper/rebalances/%"PRIu64"-%"PRIu64,
- lesser, greater);
+ return mkdatastorekey(ctx, "bookkeeper", "rebalances",
+ take(tal_fmt(NULL, "%"PRIu64"-%"PRIu64,
+ lesser, greater)));
}
void add_rebalance_pair(struct command *cmd,
struct bkpr *bkpr,
u64 created_index1, u64 created_index2)
{
- const char *path;
+ const char **path;
new_rebalance_pair(bkpr->rebalances, created_index1, created_index2);
path = ds_rebalance_path(tmpctx, created_index1, created_index2);
diff --git a/plugins/bkpr/test/run-recorder.c b/plugins/bkpr/test/run-recorder.c
index bb99085e..db05aae6 100644
--- a/plugins/bkpr/test/run-recorder.c
+++ b/plugins/bkpr/test/run-recorder.c
@@ -81,7 +81,7 @@ void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char
/* AUTOGENERATED MOCKS END */
struct command_result *jsonrpc_set_datastore_(struct command *cmd UNNEEDED,
- const char *path UNNEEDED,
+ const char **keys UNNEEDED,
const void *value UNNEEDED,
int len_or_str UNNEEDED,
const char *mode UNNEEDED,
diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c
index cebd2201..91df42a6 100644
--- a/plugins/chanbackup.c
+++ b/plugins/chanbackup.c
@@ -10,6 +10,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <common/scb_wiregen.h>
#include <errno.h>
#include <fcntl.h>
@@ -655,10 +656,11 @@ static struct command_result *commit_peer_backup(struct command *cmd,
const struct peer_backup *pb)
{
return jsonrpc_set_datastore_binary(cmd,
- tal_fmt(cmd,
- "chanbackup/peers/%s",
- fmt_node_id(tmpctx,
- &pb->peer)),
+ mkdatastorekey(tmpctx,
+ "chanbackup",
+ "peers",
+ take(fmt_node_id(NULL,
+ &pb->peer))),
pb->data, tal_bytelen(pb->data),
"create-or-replace",
NULL, NULL, NULL);
@@ -891,7 +893,7 @@ static struct command_result *handle_your_peer_storage(struct command *cmd,
return jsonrpc_set_datastore_binary(cmd,
- "chanbackup/latestscb",
+ mkdatastorekey(tmpctx, "chanbackup", "latestscb"),
decoded_bkp,
tal_bytelen(decoded_bkp),
"create-or-replace",
@@ -985,7 +987,7 @@ static struct command_result *json_restorefrompeer(struct command *cmd,
return command_param_failed();
return jsonrpc_get_datastore_binary(cmd,
- "chanbackup/latestscb",
+ mkdatastorekey(tmpctx, "chanbackup", "latestscb"),
after_latestscb,
NULL);
}
diff --git a/plugins/libplugin.c b/plugins/libplugin.c
index ac29e1d0..86305935 100644
--- a/plugins/libplugin.c
+++ b/plugins/libplugin.c
@@ -850,19 +850,19 @@ void rpc_scan(struct command *cmd,
guide, method, err);
}
-static void json_add_keypath(struct json_out *jout, const char *fieldname, const char *path)
+static void json_add_keypath(struct json_out *jout,
+ const char *fieldname,
+ const char **keys)
{
- char **parts = tal_strsplit(tmpctx, path, "/", STR_EMPTY_OK);
-
json_out_start(jout, fieldname, '[');
- for (size_t i = 0; parts[i]; parts++)
- json_out_addstr(jout, NULL, parts[i]);
+ for (size_t i = 0; i < tal_count(keys); i++)
+ json_out_addstr(jout, NULL, keys[i]);
json_out_end(jout, ']');
}
static const char *rpc_scan_datastore(const tal_t *ctx,
struct command *cmd,
- const char *path,
+ const char **keys,
const char *hex_or_string,
va_list ap)
{
@@ -871,7 +871,7 @@ static const char *rpc_scan_datastore(const tal_t *ctx,
params = json_out_new(NULL);
json_out_start(params, NULL, '{');
- json_add_keypath(params, "key", path);
+ json_add_keypath(params, "key", keys);
json_out_end(params, '}');
json_out_finished(params);
@@ -882,14 +882,14 @@ static const char *rpc_scan_datastore(const tal_t *ctx,
const char *rpc_scan_datastore_str(const tal_t *ctx,
struct command *cmd,
- const char *path,
+ const char **keys,
...)
{
const char *ret;
va_list ap;
- va_start(ap, path);
- ret = rpc_scan_datastore(ctx, cmd, path, "string", ap);
+ va_start(ap, keys);
+ ret = rpc_scan_datastore(ctx, cmd, keys, "string", ap);
va_end(ap);
return ret;
}
@@ -897,14 +897,14 @@ const char *rpc_scan_datastore_str(const tal_t *ctx,
/* This variant scans the hex encoding, not the string */
const char *rpc_scan_datastore_hex(const tal_t *ctx,
struct command *cmd,
- const char *path,
+ const char **keys,
...)
{
const char *ret;
va_list ap;
- va_start(ap, path);
- ret = rpc_scan_datastore(ctx, cmd, path, "hex", ap);
+ va_start(ap, keys);
+ ret = rpc_scan_datastore(ctx, cmd, keys, "hex", ap);
va_end(ap);
return ret;
}
@@ -925,7 +925,7 @@ void rpc_enable_batching(struct plugin *plugin)
}
struct command_result *jsonrpc_set_datastore_(struct command *cmd,
- const char *path,
+ const char **keys,
const void *value,
int len_or_str,
const char *mode,
@@ -950,7 +950,7 @@ 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);
+ json_add_keypath(req->js->jout, "key", keys);
if (len_or_str == -1)
json_add_string(req->js, "string", value);
else
@@ -1010,7 +1010,7 @@ static struct command_result *listdatastore_done(struct command *cmd,
}
struct command_result *jsonrpc_get_datastore_(struct command *cmd,
- const char *path,
+ const char **keys,
struct command_result *(*string_cb)(struct command *command,
const char *val,
void *arg),
@@ -1031,7 +1031,7 @@ struct command_result *jsonrpc_get_datastore_(struct command *cmd,
listdatastore_done, plugin_broken_cb, dsi);
tal_steal(req, dsi);
- json_add_keypath(req->js->jout, "key", path);
+ json_add_keypath(req->js->jout, "key", keys);
return send_outreq(req);
}
diff --git a/plugins/libplugin.h b/plugins/libplugin.h
index 7c4e3a25..bddba28f 100644
--- a/plugins/libplugin.h
+++ b/plugins/libplugin.h
@@ -268,7 +268,7 @@ struct json_stream *jsonrpc_stream_fail_data(struct command *cmd,
* NULL cb means ignore, NULL errcb means plugin_error.
*/
struct command_result *jsonrpc_set_datastore_(struct command *cmd,
- const char *path,
+ const char **keys,
const void *value,
int len_or_str,
const char *mode,
@@ -285,8 +285,8 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd,
void *arg)
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), -1, (mode), \
+#define jsonrpc_set_datastore_string(cmd, keys, str, mode, cb, errcb, arg) \
+ jsonrpc_set_datastore_((cmd), (keys), (str), -1, (mode), \
typesafe_cb_preargs(struct command_result *, void *, \
(cb), (arg), \
struct command *command, \
@@ -301,8 +301,8 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd,
const jsmntok_t *result), \
(arg))
-#define jsonrpc_set_datastore_binary(cmd, path, ptr, len, mode, cb, errcb, arg) \
- jsonrpc_set_datastore_((cmd), (path), (ptr), (len), (mode), \
+#define jsonrpc_set_datastore_binary(cmd, keys, ptr, len, mode, cb, errcb, arg) \
+ jsonrpc_set_datastore_((cmd), (keys), (ptr), (len), (mode), \
typesafe_cb_preargs(struct command_result *, void *, \
(cb), (arg), \
struct command *command, \
@@ -321,7 +321,7 @@ struct command_result *jsonrpc_set_datastore_(struct command *cmd,
* If the value not found, cb gets NULL @val.
*/
struct command_result *jsonrpc_get_datastore_(struct command *cmd,
- const char *path,
+ const char **keys,
struct command_result *(*string_cb)(struct command *command,
const char *val,
void *arg),
@@ -331,8 +331,8 @@ struct command_result *jsonrpc_get_datastore_(struct command *cmd,
void *arg)
NON_NULL_ARGS(1, 2);
-#define jsonrpc_get_datastore_string(cmd, path, cb, arg) \
- jsonrpc_get_datastore_((cmd), (path), \
+#define jsonrpc_get_datastore_string(cmd, keys, cb, arg) \
+ jsonrpc_get_datastore_((cmd), (keys), \
typesafe_cb_preargs(struct command_result *, \
void *, \
(cb), (arg), \
@@ -341,8 +341,8 @@ struct command_result *jsonrpc_get_datastore_(struct command *cmd,
NULL, \
(arg))
-#define jsonrpc_get_datastore_binary(cmd, path, cb, arg) \
- jsonrpc_get_datastore_((cmd), (path), \
+#define jsonrpc_get_datastore_binary(cmd, keys, cb, arg) \
+ jsonrpc_get_datastore_((cmd), (keys), \
NULL, \
typesafe_cb_preargs(struct command_result *, \
void *, \
@@ -456,17 +456,17 @@ void rpc_scan(struct command *cmd,
...);
/* Helper to scan datastore. Returns error msg (usually meaning field
- * does not exist), or NULL on success. path is /-separated. Final
+ * does not exist), or NULL on success. keys is usually from mkdatastorekey. Final
* arg is JSON_SCAN or JSON_SCAN_TAL.
*/
const char *rpc_scan_datastore_str(const tal_t *ctx,
struct command *cmd,
- const char *path,
+ const char **keys,
...);
/* This variant scans the hex encoding, not the string */
const char *rpc_scan_datastore_hex(const tal_t *ctx,
struct command *cmd,
- const char *path,
+ const char **keys,
...);
/* This sets batching of database commitments */
diff --git a/tests/plugins/test_libplugin.c b/tests/plugins/test_libplugin.c
index 774e0424..a89b6164 100644
--- a/tests/plugins/test_libplugin.c
+++ b/tests/plugins/test_libplugin.c
@@ -4,6 +4,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <common/mkdatastorekey.h>
#include <plugins/libplugin.h>
/* Stash this in plugin's data */
@@ -37,7 +38,7 @@ static struct command_result *get_ds_bin_done(struct command *cmd,
val ? tal_hex(tmpctx, val) : "NOT FOUND");
return jsonrpc_get_datastore_string(cmd,
- "test_libplugin/name",
+ mkdatastorekey(tmpctx, "test_libplugin", "name"),
get_ds_done, arg);
}
@@ -64,7 +65,7 @@ static struct command_result *json_helloworld(struct command *cmd,
if (!name)
return jsonrpc_get_datastore_binary(cmd,
- "test_libplugin/name",
+ mkdatastorekey(tmpctx, "test_libplugin", "name"),
get_ds_bin_done,
"hello");
@@ -299,12 +300,14 @@ static const char *init(struct command *init_cmd,
return "Disabled via selfdisable option";
/* Test rpc_scan_datastore funcs */
- err_str = rpc_scan_datastore_str(tmpctx, init_cmd, "test_libplugin/name",
+ err_str = rpc_scan_datastore_str(tmpctx, init_cmd,
+ mkdatastorekey(tmpctx, "test_libplugin", "name"),
JSON_SCAN_TAL(tmpctx, json_strdup,
&name));
if (err_str)
name = NULL;
- err_hex = rpc_scan_datastore_hex(tmpctx, init_cmd, "test_libplugin/name",
+ err_hex = rpc_scan_datastore_hex(tmpctx, init_cmd,
+ mkdatastorekey(tmpctx, "test_libplugin", "name"),
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
&binname));
if (err_hex)
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.