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

Function fillin_missing_channel_id

wallet/db.c:248–282  ·  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

246 * are now two ways to do it, we save the derived channel id.
247 */
248void 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
284void fillin_missing_local_basepoints(struct lightningd *ld,
285 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
derive_channel_idFunction · 0.85
db_bind_channel_idFunction · 0.85
db_bind_u64Function · 0.85
db_exec_prepared_v2Function · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected