* V2 channel open has a different channel_id format than v1. prior to this, we * could simply derive the channel_id whenever it was required, but since there * are now two ways to do it, we save the derived channel id. */
| 1153 | * are now two ways to do it, we save the derived channel id. |
| 1154 | */ |
| 1155 | static void fillin_missing_channel_id(struct lightningd *ld, struct db *db, |
| 1156 | const struct migration_context *mc) |
| 1157 | { |
| 1158 | |
| 1159 | struct db_stmt *stmt; |
| 1160 | |
| 1161 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 1162 | " id" |
| 1163 | ", funding_tx_id" |
| 1164 | ", funding_tx_outnum" |
| 1165 | " FROM channels;")); |
| 1166 | |
| 1167 | db_query_prepared(stmt); |
| 1168 | while (db_step(stmt)) { |
| 1169 | struct db_stmt *update_stmt; |
| 1170 | size_t id; |
| 1171 | struct bitcoin_outpoint funding; |
| 1172 | struct channel_id cid; |
| 1173 | |
| 1174 | id = db_col_u64(stmt, "id"); |
| 1175 | db_col_txid(stmt, "funding_tx_id", &funding.txid); |
| 1176 | funding.n = db_col_int(stmt, "funding_tx_outnum"); |
| 1177 | derive_channel_id(&cid, &funding); |
| 1178 | |
| 1179 | update_stmt = db_prepare_v2(db, SQL("UPDATE channels" |
| 1180 | " SET full_channel_id = ?" |
| 1181 | " WHERE id = ?;")); |
| 1182 | db_bind_channel_id(update_stmt, 0, &cid); |
| 1183 | db_bind_u64(update_stmt, 1, id); |
| 1184 | |
| 1185 | db_exec_prepared_v2(update_stmt); |
| 1186 | tal_free(update_stmt); |
| 1187 | } |
| 1188 | |
| 1189 | tal_free(stmt); |
| 1190 | } |
| 1191 | |
| 1192 | static void fillin_missing_local_basepoints(struct lightningd *ld, |
| 1193 | struct db *db, |
nothing calls this directly
no test coverage detected