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

Function fillin_missing_channel_blockheights

wallet/db.c:347–369  ·  view source on GitHub ↗

New 'channel_blockheights' table, every existing channel gets a * 'initial blockheight' of 0 */

Source from the content-addressed store, hash-verified

345/* New 'channel_blockheights' table, every existing channel gets a
346 * 'initial blockheight' of 0 */
347void fillin_missing_channel_blockheights(struct lightningd *ld,
348 struct db *db)
349{
350 struct db_stmt *stmt;
351
352 /* Set all existing channels to 0 */
353 /* If we're funder (LOCAL=0):
354 * Then our blockheight is set last (SENT_ADD_ACK_REVOCATION = 4) */
355 stmt = db_prepare_v2(db,
356 SQL("INSERT INTO channel_blockheights"
357 " (channel_id, hstate, blockheight)"
358 " SELECT id, 4, 0 FROM channels"
359 " WHERE funder = 0;"));
360 db_exec_prepared_v2(take(stmt));
361 /* If they're funder (REMOTE=1):
362 * Then their blockheight is last (RCVD_ADD_ACK_REVOCATION = 14) */
363 stmt = db_prepare_v2(db,
364 SQL("INSERT INTO channel_blockheights"
365 " (channel_id, hstate, blockheight)"
366 " SELECT id, 14, 0 FROM channels"
367 " WHERE funder = 1;"));
368 db_exec_prepared_v2(take(stmt));
369}
370
371void
372migrate_inflight_last_tx_to_psbt(struct lightningd *ld, struct db *db)

Callers

nothing calls this directly

Calls 1

db_exec_prepared_v2Function · 0.85

Tested by

no test coverage detected