We required local aliases to be set on established channels, * but we forgot about already-existing ones in the db! */
| 987 | /* We required local aliases to be set on established channels, |
| 988 | * but we forgot about already-existing ones in the db! */ |
| 989 | void 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 */ |
| 1015 | void insert_addrtype_to_addresses(struct lightningd *ld, |
nothing calls this directly
no test coverage detected