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

Function revert_withheld_column

wallet/migrations.c:20–53  ·  view source on GitHub ↗

Don't allow downgrade if they've *used* the withheld column. */

Source from the content-addressed store, hash-verified

18
19/* Don't allow downgrade if they've *used* the withheld column. */
20static const char *revert_withheld_column(const tal_t *ctx, struct db *db)
21{
22 struct db_stmt *stmt;
23 struct channel_id *cid;
24 struct short_channel_id *scid;
25
26 stmt = db_prepare_v2(db, SQL("SELECT full_channel_id, scid FROM channels WHERE withheld != 0"));
27 db_query_prepared(stmt);
28 if (db_step(stmt)) {
29 cid = tal(tmpctx, struct channel_id);
30 db_col_channel_id(stmt, "full_channel_id", cid);
31 if (db_col_is_null(stmt, "scid"))
32 scid = NULL;
33 else {
34 scid = tal(tmpctx, struct short_channel_id);
35 *scid = db_col_short_channel_id(stmt, "scid");
36 }
37 } else {
38 cid = NULL;
39 scid = NULL;
40 }
41 tal_free(stmt);
42
43 if (cid) {
44 return tal_fmt(tmpctx, "Channel %s (%s) used v25.12's withheld flag",
45 fmt_channel_id(tmpctx, cid),
46 scid ? fmt_short_channel_id(tmpctx, *scid) : "no short channel id");
47 }
48
49 /* For sqlite3 needs "2021-03-12 (3.35.0)" or above */
50 stmt = db_prepare_v2(db, SQL("ALTER TABLE channels DROP COLUMN withheld"));
51 db_exec_prepared_v2(take(stmt));
52 return NULL;
53}
54
55/* Do not reorder or remove elements from this array, it is used to
56 * migrate existing databases from a previous state, based on the

Callers

nothing calls this directly

Calls 9

db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_channel_idFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_short_channel_idFunction · 0.85
tal_freeFunction · 0.85
fmt_short_channel_idFunction · 0.85
db_exec_prepared_v2Function · 0.85
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected