* 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. */
| 246 | * are now two ways to do it, we save the derived channel id. |
| 247 | */ |
| 248 | void fillin_missing_channel_id(struct lightningd *ld, struct db *db) |
| 249 | { |
| 250 | |
| 251 | struct db_stmt *stmt; |
| 252 | |
| 253 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 254 | " id" |
| 255 | ", funding_tx_id" |
| 256 | ", funding_tx_outnum" |
| 257 | " FROM channels;")); |
| 258 | |
| 259 | db_query_prepared(stmt); |
| 260 | while (db_step(stmt)) { |
| 261 | struct db_stmt *update_stmt; |
| 262 | size_t id; |
| 263 | struct bitcoin_outpoint funding; |
| 264 | struct channel_id cid; |
| 265 | |
| 266 | id = db_col_u64(stmt, "id"); |
| 267 | db_col_txid(stmt, "funding_tx_id", &funding.txid); |
| 268 | funding.n = db_col_int(stmt, "funding_tx_outnum"); |
| 269 | derive_channel_id(&cid, &funding); |
| 270 | |
| 271 | update_stmt = db_prepare_v2(db, SQL("UPDATE channels" |
| 272 | " SET full_channel_id = ?" |
| 273 | " WHERE id = ?;")); |
| 274 | db_bind_channel_id(update_stmt, &cid); |
| 275 | db_bind_u64(update_stmt, id); |
| 276 | |
| 277 | db_exec_prepared_v2(update_stmt); |
| 278 | tal_free(update_stmt); |
| 279 | } |
| 280 | |
| 281 | tal_free(stmt); |
| 282 | } |
| 283 | |
| 284 | void fillin_missing_local_basepoints(struct lightningd *ld, |
| 285 | struct db *db) |
nothing calls this directly
no test coverage detected