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

Function fillin_missing_channel_blockheights

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

1254/* New 'channel_blockheights' table, every existing channel gets a
1255 * 'initial blockheight' of 0 */
1256static void fillin_missing_channel_blockheights(struct lightningd *ld,
1257 struct db *db,
1258 const struct migration_context *mc)
1259{
1260 struct db_stmt *stmt;
1261
1262 /* Set all existing channels to 0 */
1263 /* If we're funder (LOCAL=0):
1264 * Then our blockheight is set last (SENT_ADD_ACK_REVOCATION = 4) */
1265 stmt = db_prepare_v2(db,
1266 SQL("INSERT INTO channel_blockheights"
1267 " (channel_id, hstate, blockheight)"
1268 " SELECT id, 4, 0 FROM channels"
1269 " WHERE funder = 0;"));
1270 db_exec_prepared_v2(take(stmt));
1271 /* If they're funder (REMOTE=1):
1272 * Then their blockheight is last (RCVD_ADD_ACK_REVOCATION = 14) */
1273 stmt = db_prepare_v2(db,
1274 SQL("INSERT INTO channel_blockheights"
1275 " (channel_id, hstate, blockheight)"
1276 " SELECT id, 14, 0 FROM channels"
1277 " WHERE funder = 1;"));
1278 db_exec_prepared_v2(take(stmt));
1279}
1280
1281void
1282migrate_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