| 101 | } |
| 102 | |
| 103 | struct db *db_setup(const tal_t *ctx, struct lightningd *ld, |
| 104 | const struct ext_key *bip32_base) |
| 105 | { |
| 106 | struct db *db = db_open(ctx, ld->wallet_dsn, ld->developer, true, |
| 107 | db_error, ld); |
| 108 | bool migrated; |
| 109 | |
| 110 | db->report_changes_fn = plugin_hook_db_sync; |
| 111 | |
| 112 | db_begin_transaction(db); |
| 113 | db->data_version = db_data_version_get(db); |
| 114 | |
| 115 | migrated = db_migrate(ld, db, bip32_base); |
| 116 | |
| 117 | db_commit_transaction(db); |
| 118 | |
| 119 | db->in_migration = false; |
| 120 | |
| 121 | /* This needs to be done outside a transaction, apparently. |
| 122 | * It's a good idea to do this every so often, and on db |
| 123 | * upgrade is a reasonable time. */ |
| 124 | if (migrated && !db->config->vacuum_fn(db)) |
| 125 | db_fatal(db, "Error vacuuming db: %s", db->error); |
| 126 | |
| 127 | return db; |
| 128 | } |
| 129 | |
| 130 | /* Will apply the current config fee settings to all channels */ |
| 131 | void migrate_pr2342_feerate_per_channel(struct lightningd *ld, struct db *db) |