From 8df29db48f5b05993b01f7adb2fdfd560c2e6bda Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 25 Jul 2023 11:08:43 +0930 Subject: [PATCH] runes: fix `stored` field. The uid isn't enough: it could be someone else's rune. This is tested in the command rune list tests. Signed-off-by: Rusty Russell --- lightningd/runes.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lightningd/runes.c b/lightningd/runes.c index e4a2f3f5b..2dd27c438 100644 --- a/lightningd/runes.c +++ b/lightningd/runes.c @@ -326,8 +326,11 @@ static struct command_result *json_showrunes(struct command *cmd, json_array_start(response, "runes"); if (ras) { long uid = atol(ras->rune->unique_id); - bool in_db = (wallet_get_rune(tmpctx, cmd->ld->wallet, uid) != NULL); - json_add_rune(cmd->ld, response, NULL, ras->runestr, ras->rune, in_db); + const char *from_db = wallet_get_rune(tmpctx, cmd->ld->wallet, uid); + + /* We consider it stored iff this is exactly stored */ + json_add_rune(cmd->ld, response, NULL, ras->runestr, ras->rune, + from_db && streq(from_db, ras->runestr)); } else { const char **strs = wallet_get_runes(cmd, cmd->ld->wallet); for (size_t i = 0; i < tal_count(strs); i++) {