MCPcopy Create free account
hub / github.com/ElementsProject/lightning / migrate_initialize_alias_local

Function migrate_initialize_alias_local

wallet/db.c:989–1012  ·  view source on GitHub ↗

We required local aliases to be set on established channels, * but we forgot about already-existing ones in the db! */

Source from the content-addressed store, hash-verified

987/* We required local aliases to be set on established channels,
988 * but we forgot about already-existing ones in the db! */
989void migrate_initialize_alias_local(struct lightningd *ld,
990 struct db *db)
991{
992 struct db_stmt *stmt;
993 u64 *ids = tal_arr(tmpctx, u64, 0);
994
995 stmt = db_prepare_v2(db, SQL("SELECT id FROM channels"
996 " WHERE alias_local IS NULL;"));
997 db_query_prepared(stmt);
998 while (db_step(stmt))
999 tal_arr_expand(&ids, db_col_u64(stmt, "id"));
1000 tal_free(stmt);
1001
1002 for (size_t i = 0; i < tal_count(ids); i++) {
1003 stmt = db_prepare_v2(db, SQL("UPDATE channels"
1004 " SET alias_local = ?"
1005 " WHERE id = ?;"));
1006 /* We don't even check for clashes! */
1007 db_bind_short_channel_id(stmt, random_scid());
1008 db_bind_u64(stmt, ids[i]);
1009 db_exec_prepared_v2(stmt);
1010 tal_free(stmt);
1011 }
1012}
1013
1014/* Insert address type as `ADDR_ALL` for issued addresses */
1015void insert_addrtype_to_addresses(struct lightningd *ld,

Callers

nothing calls this directly

Calls 8

db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_u64Function · 0.85
tal_freeFunction · 0.85
db_bind_short_channel_idFunction · 0.85
random_scidFunction · 0.85
db_bind_u64Function · 0.85
db_exec_prepared_v2Function · 0.85

Tested by

no test coverage detected