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

Function fillin_missing_channel_id

wallet/db.c:1155–1190  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

1153 * are now two ways to do it, we save the derived channel id.
1154 */
1155static 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
1192static void fillin_missing_local_basepoints(struct lightningd *ld,
1193 struct db *db,

Callers

nothing calls this directly

Calls 10

db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_u64Function · 0.85
db_col_txidFunction · 0.85
db_col_intFunction · 0.85
db_bind_channel_idFunction · 0.85
db_bind_u64Function · 0.85
db_exec_prepared_v2Function · 0.85
tal_freeFunction · 0.85
derive_channel_idFunction · 0.50

Tested by

no test coverage detected