diff --git a/src/wallet/sqlite.h b/src/wallet/sqlite.h --- a/src/wallet/sqlite.h +++ b/src/wallet/sqlite.h @@ -7,13 +7,15 @@ #include +#include + struct bilingual_str; class SQLiteDatabase; /** RAII class that provides access to a WalletDatabase */ class SQLiteBatch : public DatabaseBatch { private: - SQLiteDatabase &m_database; + [[maybe_unused]] SQLiteDatabase &m_database; bool ReadKey(CDataStream &&key, CDataStream &value) override; bool WriteKey(CDataStream &&key, CDataStream &&value, @@ -23,6 +25,7 @@ public: explicit SQLiteBatch(SQLiteDatabase &database); + ~SQLiteBatch() override { Close(); } /** No-op. See comment on SQLiteDatabase::Flush */ void Flush() override {} @@ -93,6 +96,8 @@ /** Make a SQLiteBatch connected to this database */ std::unique_ptr MakeBatch(bool flush_on_close = true) override; + + sqlite3 *m_db{nullptr}; }; bool ExistsSQLiteDatabase(const fs::path &path); diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp --- a/src/wallet/sqlite.cpp +++ b/src/wallet/sqlite.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -16,9 +17,16 @@ SQLiteDatabase::SQLiteDatabase(const fs::path &dir_path, const fs::path &file_path, bool mock) : WalletDatabase(), m_mock(mock), m_dir_path(dir_path.string()), - m_file_path(file_path.string()) {} + m_file_path(file_path.string()) { + LogPrintf("Using SQLite Version %s\n", SQLiteDatabaseVersion()); + LogPrintf("Using wallet %s\n", m_dir_path); -SQLiteDatabase::~SQLiteDatabase() {} + Open(); +} + +SQLiteDatabase::~SQLiteDatabase() { + Close(); +} void SQLiteDatabase::Open() {} @@ -36,6 +44,8 @@ return nullptr; } +SQLiteBatch::SQLiteBatch(SQLiteDatabase &database) : m_database(database) {} + void SQLiteBatch::Close() {} bool SQLiteBatch::ReadKey(CDataStream &&key, CDataStream &value) {