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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-25 11:08:43 +09:30
parent 49fdc0df99
commit 8df29db48f

View File

@@ -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++) {