mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
runes: insert rune with correct id field.
"id" is a magic name, so it was being populated by sqlite3 automatically, starting at 0. Fortunately, we only fetched by id in one place: to indicate the `stored` flag when asked about an explicit rune in `showrunes`. Reported-by: @ShahanaFarooqui Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: JSON-RPC: `showrunes` on a specific rune would always say `stored`: false.
This commit is contained in:
parent
7429b1e7e1
commit
2de304314a
3 changed files with 6 additions and 7 deletions
|
@ -471,7 +471,6 @@ def test_commando_blacklist_migration(node_factory):
|
|||
{'start': 9, 'end': 9}]}
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_showrune_id(node_factory):
|
||||
l1 = node_factory.get_node()
|
||||
|
||||
|
|
|
@ -5712,20 +5712,20 @@ const char **wallet_get_runes(const tal_t *ctx, struct wallet *wallet)
|
|||
return strs;
|
||||
}
|
||||
|
||||
static void db_rune_insert(struct db *db, struct rune *rune)
|
||||
static void db_rune_insert(struct db *db,
|
||||
const struct rune *rune)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
|
||||
assert(rune->unique_id != NULL);
|
||||
|
||||
stmt = db_prepare_v2(db,
|
||||
SQL("INSERT INTO runes (rune) VALUES (?);"));
|
||||
SQL("INSERT INTO runes (id, rune) VALUES (?, ?);"));
|
||||
db_bind_u64(stmt, atol(rune->unique_id));
|
||||
db_bind_text(stmt, rune_to_base64(tmpctx, rune));
|
||||
db_exec_prepared_v2(stmt);
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
||||
void wallet_rune_insert(struct wallet *wallet, struct rune *rune)
|
||||
void wallet_rune_insert(struct wallet *wallet, const struct rune *rune)
|
||||
{
|
||||
db_rune_insert(wallet->db, rune);
|
||||
}
|
||||
|
|
|
@ -1603,7 +1603,7 @@ const char **wallet_get_runes(const tal_t *ctx, struct wallet *wallet);
|
|||
* @wallet: the wallet to save into
|
||||
* @rune: the instance to store
|
||||
*/
|
||||
void wallet_rune_insert(struct wallet *wallet, struct rune *rune);
|
||||
void wallet_rune_insert(struct wallet *wallet, const struct rune *rune);
|
||||
|
||||
/* Load the runes blacklist */
|
||||
struct rune_blacklist {
|
||||
|
|
Loading…
Add table
Reference in a new issue