| 240 | } |
| 241 | |
| 242 | static sqlite3 *db_setup(struct plugin *p, const char *db_dsn) |
| 243 | { |
| 244 | sqlite3_stmt *stmt; |
| 245 | sqlite3 *sql; |
| 246 | int err; |
| 247 | |
| 248 | err = sqlite3_open_v2(db_dsn, &sql, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, NULL); |
| 249 | assert(err == SQLITE_OK); |
| 250 | |
| 251 | err = sqlite3_extended_result_codes(sql, 1); |
| 252 | assert(err == SQLITE_OK); |
| 253 | |
| 254 | sqlite3_busy_timeout(sql, 60000); |
| 255 | sqlite3_prepare_v2(sql, |
| 256 | "PRAGMA foreign_keys = ON;", -1, &stmt, NULL); |
| 257 | err = sqlite3_step(stmt); |
| 258 | assert(err == SQLITE_DONE); |
| 259 | sqlite3_finalize(stmt); |
| 260 | |
| 261 | db_migrate(p, sql); |
| 262 | return sql; |
| 263 | } |
| 264 | |
| 265 | static int sqlite3_bind_outpoint(sqlite3_stmt *stmt, int pos, const struct bitcoin_outpoint *o) |
| 266 | { |
no test coverage detected