aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/sqlite.cpp
AgeCommit message (Collapse)Author
2022-05-21scripted-diff: Convert global Mutexes to GlobalMutexesAnthony Towns
-BEGIN VERIFY SCRIPT- sed -i -E -e '/^([a-z]+ )?Mutex [a-z]/ s/Mutex/GlobalMutex/' $(git grep -lE '^([a-z]+ )?Mutex [a-z]') -END VERIFY SCRIPT-
2022-04-26scripted-diff: rename BytePtr to AsBytePtrJoão Barbosa
Building with iPhoneOS SDK fails because it also has `BytePtr` defined in /usr/include/MacTypes.h. -BEGIN VERIFY SCRIPT- sed -i 's/BytePtr/AsBytePtr/' $(git grep -l "BytePtr" src) -END VERIFY SCRIPT-
2022-03-24Merge bitcoin/bitcoin#23732: refactor: Remove `gArgs` from `bdb.h` and ↵MarcoFalke
`sqlite.h` 39b1763730177cd7d6a32fd9321da640b0d65e0e Replace use of `ArgsManager` with `DatabaseOptions` (Kiminuo) Pull request description: Contributes to #21005. The goal of this PR is to remove `gArgs` from database classes (i.e. `bdb.h` and `sqlite.h`) so that they can be tested without relying on `gArgs` in tests. Notes: * My goal is to enable unit-testing without relying on `gArgs` as much as possible. Global variables are hard to reason about which in turn makes it slightly harder to contribute to this codebase. When the compiler does the heavy lifting for us and allows us only to construct an object (or call a method) with valid parameters, we may also save some time in code reviews. The cost for this is passing an argument which is not for free but the cost is very miniscule compared to benefits, I think. * GUI code is an exception because it seems fine to have `gArgs` there so I don't plan to make changes in `src/qt` folder, for example. * My approach to removal of `gArgs` uses is moving from lower levels to upper ones and pass `ArgsManager` as an argument as needed. The approach is very similar to what #20158. ACKs for top commit: achow101: ACK 39b1763730177cd7d6a32fd9321da640b0d65e0e ryanofsky: Code review ACK 39b1763730177cd7d6a32fd9321da640b0d65e0e. Just the two small ReadDatabaseArgs and Berkeley open changes that were discussed since the last review Tree-SHA512: aa066b314db593e46c18698fe8cdd500f558b405dc04e4a9a3ff57b52b5b3a81a6cb090e0e661785d1d02c1bf18958c1f4cd715ff233aab63381e3f80960622d
2022-03-16Replace use of `ArgsManager` with `DatabaseOptions`Kiminuo
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-03-06wallet: refactor: dedup sqlite blob bindingSebastian Falbesoner
2022-01-27Merge bitcoin/bitcoin#23438: refactor: Use spans of std::byte in serializelaanwj
fa5d2e678c809c26bd40d7e7c171529d3ffb5903 Remove unused char serialize (MarcoFalke) fa24493d6394b3a477535f480664c9596f18e3c5 Use spans of std::byte in serialize (MarcoFalke) fa65bbf217b725ada35107b4ad646d250228355c span: Add BytePtr helper (MarcoFalke) Pull request description: This changes the serialize code (`.read()` and `.write()` functions) to take a `Span` instead of a pointer and size. This is a breaking change for the serialize interface, so at no additional cost we can also switch to `std::byte` (instead of using `char`). The benefits of using `Span`: * Less verbose and less fragile code when passing an already existing `Span`(-like) object to or from serialization The benefits of using `std::byte`: * `std::byte` can't accidentally be mistaken for an integer The goal here is to only change serialize to use spans of `std::byte`. If needed, `AsBytes`, `MakeUCharSpan`, ... can be used (temporarily) to pass spans of the right type. Other changes that are included here: * [#22167](https://github.com/bitcoin/bitcoin/pull/22167) (refactor: Remove char serialize by MarcoFalke) * [#21906](https://github.com/bitcoin/bitcoin/pull/21906) (Preserve const in cast on CTransactionSignatureSerializer by promag) ACKs for top commit: laanwj: Concept and code review ACK fa5d2e678c809c26bd40d7e7c171529d3ffb5903 sipa: re-utACK fa5d2e678c809c26bd40d7e7c171529d3ffb5903 Tree-SHA512: 08ee9eced5fb777cedae593b11e33660bed9a3e1711a7451a87b835089a96c99ce0632918bb4666a4e859c4d020f88fb50f2dd734216b0c3d1a9a704967ece6f
2022-01-06Add src/wallet/* code to wallet:: namespaceRussell Yanofsky
2022-01-02Use spans of std::byte in serializeMarcoFalke
This switches .read() and .write() to take spans of bytes.
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-10-20wallet: Use PACKAGE_NAME to mention our softwareHennadii Stepanov
2021-10-05refactor: Block unsafe fs::path std::string conversion callsRussell Yanofsky
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding calls to methods which will be unsafe after the transaction to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Kiminuo <kiminuo@protonmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2021-09-28wallet: enable SQLite extended result codesSebastian Falbesoner
With this change, we get more fine-grained error messages if something goes wrong in the course of communicating with the SQLite database. To pick some random examples, the error codes SQLITE_IOERR_NOMEM, SQLITE_IOERR_CORRUPTFS or SQLITE_IOERR_FSYNC are way more specific than just a plain SQLITE_IOERR, and the corresponding error messages generated by sqlite3_errstr() will hence give a better hint to the user (or also to the developers, if an error report is sent) what the cause for a failure is.
2021-05-17wallet: refactor: dedup sqlite PRAGMA assignmentsSebastian Falbesoner
2021-05-17wallet: refactor: dedup sqlite PRAGMA integer readsSebastian Falbesoner
2021-04-12tests: Skip SQLite fsyncs while testingAndrew Chow
Since we want tests to run quickly, and since tests do a lot more db operations than expected we expect to see in actual usage, we disable sqlite's syncing behavior to make db operations run much faster. This syncing behavior is necessary for normal operation as it helps guarantee that data won't become lost or corrupted, but in tests, we don't care about that.
2021-04-02wallet: refactor: dedup sqlite statement deletionsSebastian Falbesoner
2021-04-02wallet: refactor: dedup sqlite statement preparationsSebastian Falbesoner
2021-03-11scripted-diff: remove MakeUnique<T>()fanquake
-BEGIN VERIFY SCRIPT- git rm src/util/memory.h sed -i -e 's/MakeUnique/std::make_unique/g' $(git grep -l MakeUnique src) sed -i -e '/#include <util\/memory.h>/d' $(git grep -l '#include <util/memory.h>' src) sed -i -e '/util\/memory.h \\/d' src/Makefile.am -END VERIFY SCRIPT-
2020-12-04refactor: Consolidate redundant wallet database path and exists functionsRussell Yanofsky
No change in behavior. Just remove a little bit of code, reduce macro usage, remove duplicative functions, and make BDB and SQLite implementations more consistent with each other.
2020-12-04MOVEONLY: Move IsBDBFile, IsSQLiteFile, and ListWalletDirRussell Yanofsky
This commit does not change to any code and behavior. It it is easily reviewed with the --color-moved=dimmed_zebra git diff option. Motivation for this change is to: - Consolidate redundant functions IsBDBFile /ExistsBerkeleyDatabase / SplitWalletPath, and IsSQLiteFile / ExistsSQLiteDatabase in the next commits - Detect SQLite wallets consistently regardless whether bitcoin is built with SQLite support in the next commits - Avoid attempting to open SQLite databases with the BDB library when bitcoin is built without SQLite support in the next commits
2020-11-18Fix mock SQLiteDatabasesAndrew Chow
2020-11-05wallet: Set DatabaseStatus::SUCCESS in MakeSQLiteDatabaseMarcoFalke
2020-11-05Set bilingual error completelyHennadii Stepanov
2020-10-22wallet: fix buffer over-read in SQLite file magic checkSebastian Falbesoner
If there is no terminating zero within the 16 magic bytes, the buffer would be over-read in the std::string constructor. Fixed by using the "from buffer" variant of the ctor (that also takes a size) rather than the "from c-string" variant.
2020-10-14wallet: Enforce sqlite serialized threading modeAndrew Chow
2020-10-14Set and check the sqlite user versionAndrew Chow
2020-10-14Use network magic as sqlite wallet application IDAndrew Chow
2020-10-14Determine wallet file type based on file magicAndrew Chow
2020-10-14Implement SQLiteDatabase::MakeBatchAndrew Chow
2020-10-14Implement SQLiteDatabase::VerifyAndrew Chow
2020-10-14Implement SQLiteDatabase::RewriteAndrew Chow
Rewrite uses the VACUUM command which does exactly what we want. A specific advertised use case is to compact a database and ensure that any deleted data is actually deleted.
2020-10-14Implement SQLiteDatabase::TxnBegin, TxnCommit, and TxnAbortAndrew Chow
2020-10-14Implement SQLiteDatabase::BackupAndrew Chow
2020-10-14Implement SQLiteBatch::StartCursor, ReadAtCursor, and CloseCursorAndrew Chow
2020-10-14Implement SQLiteBatch::ReadKey, WriteKey, EraseKey, and HasKeyAndrew Chow
2020-10-14Add SetupSQLStatementsAndrew Chow
2020-10-14Implement SQLiteBatch::CloseAndrew Chow
2020-10-14Implement SQLiteDatabase::CloseAndrew Chow
2020-10-14Implement SQLiteDatabase::OpenAndrew Chow
2020-10-14Initialize and Shutdown sqlite3 globalsAndrew Chow
sqlite3 recommends that sqlite3_initialize be called when the application starts, and sqlite3_shutdown when it stops. Since we don't always use sqlite3, we initialize it when a SQLiteDatabse is constructed (calling sqlite3_initialize after initialized is a no-op). We call sqlite3_shutdown when we see that there are no databases opened. The number of open databases is tracked by an atomic g_dbs_open.
2020-10-14Constructors, destructors, and relevant private fields for SQLiteDatabase/BatchAndrew Chow
2020-10-14Implement SQLiteDatabaseVersionAndrew Chow
2020-10-14Add SQLiteDatabase and SQLiteBatch dummy classesAndrew Chow