aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/db.h
Commit message (Collapse)AuthorAgeFilesLines
* rpc, wallet: Expose database format in getwalletinfoJoão Barbosa2020-10-141-0/+3
|
* Determine wallet file type based on file magicAndrew Chow2020-10-141-0/+3
|
* wallet: remove db mode stringIvan Metlushko2020-10-131-4/+4
| | | | | | | | | We never need to open database in read-only mode as it's controlled separately for every batch. Also we can safely create database if it doesn't exist already because require_existing option is verified in MakeDatabase before creating a new WalletDatabase instance.
* bugfix: make LoadWallet assigns status alwaysAkio Nakamura2020-09-101-0/+1
| | | | | | | | Although loadwallet() in rpcwallet.cpp assumes LoadWallet() always assign some value to the 'status', but LoadWallet() does not do so in some situation. This fixes above and prevends loadwallet() returns ambiguous error code.
* refactor: Pass wallet database into CWallet::CreateRussell Yanofsky2020-09-031-4/+4
| | | | No changes in behavior
* wallet: Remove Verify and IsLoaded methodsRussell Yanofsky2020-09-031-4/+0
| | | | | | | | Checks are now consolidated in MakeBerkeleyDatabase function instead of happening in higher level code. This commit does not change behavior except for error messages which now include more complete information.
* refactor: Use DatabaseStatus and DatabaseOptions typesRussell Yanofsky2020-09-031-0/+5
| | | | No changes in behavior. Just replaces arguments and return types
* wallet: Add MakeDatabase functionRussell Yanofsky2020-09-031-0/+22
| | | | | | | | | | | | New function is not currently called but will be called in upcoming commits. It moves database path checking, and existence checking, and already-loaded checking, and verification into a single function so this logic does not need to be repeated all over higher level wallet code, and so higher level code does not need to change when SQLite support is added in https://github.com/bitcoin/bitcoin/pull/19077. This also lets higher level wallet code make fewer assumptions about the contents of wallet directories. This commit just adds the new function and does not change behavior in any way.
* Introduce DummyDatabase and use it in the testsAndrew Chow2020-07-291-0/+41
|
* walletdb: Introduce WalletDatabase abstract classAndrew Chow2020-07-141-0/+60
| | | | | Make WalletDatabase actually an abstract class and not just a typedef for BerkeleyDatabase. Have BerkeleyDatabase inherit this class.
* walletdb: Refactor DatabaseBatch abstract class from BerkeleyBatchAndrew Chow2020-07-091-0/+80
|
* walletdb: Move BDB specific things into bdb.{cpp/h}Andrew Chow2020-06-151-323/+0
| | | | | Leave wallet/db.{cpp/h} for generic WalletDatabase stuff. The BDB specific stuff goes into bdb.{cpp/h}
* walletdb: moveonly: Move BerkeleyBatch Cursor and Txn funcs to cppAndrew Chow2020-06-151-60/+5
| | | | Put the implementation in the cpp, not the h file.
* walletdb: move IsWalletLoaded to walletdb.cppAndrew Chow2020-06-151-1/+0
|
* walletdb: Add IsBDBWalletLoaded to look for BDB wallets specificallyAndrew Chow2020-06-151-0/+1
|
* walletdb: Make SpliWalletFilePath non-staticAndrew Chow2020-06-151-0/+1
|
* Move RecoverDatabaseFile and RecoverKeysOnlyFilter into salvage.{cpp/h}Andrew Chow2020-05-251-2/+0
|
* Make BerkeleyBatch::Recover and WalletBatch::RecoverKeysOnlyFilter standaloneAndrew Chow2020-05-251-1/+2
| | | | | | Instead of having these be class static functions, just make them be standalone. Also removes WalletBatch::Recover which just passed through to BerkeleyBatch::Recover.
* Move BerkeleyEnvironment::Salvage into BerkeleyBatch::RecoverAndrew Chow2020-05-251-9/+0
|
* walletdb: remove fAggressive from SalvageAndrew Chow2020-05-251-1/+1
| | | | | The only call to Salvage set fAggressive = true so remove that parameter and always use DB_AGGRESSIVE
* walletdb: don't automatically salvage when corruption is detectedAndrew Chow2020-05-251-12/+2
|
* build: Enable -Wsuggest-overrideHennadii Stepanov2020-05-121-0/+7
|
* refactor: Add BerkeleyDatabaseVersion() functionHennadii Stepanov2020-05-111-0/+2
|
* wallet: Avoid translating RPC errors when loading walletsMarcoFalke2020-05-011-2/+4
| | | | | | | Common errors and warnings should be translated when displayed in the GUI, but not translated when displayed elsewhere. The wallet method CreateWalletFromFile does not know its caller, so this commit changes it to return a bilingual_str to the caller.
* scripted-diff: Bump copyright headersMarcoFalke2020-04-161-1/+1
| | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
* wallet/db: make IsDummy() constKarl-Johan Alm2020-03-021-1/+1
| | | | This method does a simple check and no modifications.
* wallet/db: make Backup() constKarl-Johan Alm2020-03-021-1/+1
| | | | This method is the to-disk equivalent of serialize methods which are also const.
* Merge #17070: wallet: Avoid showing GUI popups on RPC errorsWladimir J. van der Laan2019-10-211-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | facec1c643105d0ae74b5d32cf33d593f9e82a36 wallet: Avoid showing GUI popups on RPC errors (MarcoFalke) Pull request description: RPC errors and warnings are shown as popups in the GUI instead of being returned to the RPC caller. For example, ``` $ ./src/bitcoin-cli loadwallet $(pwd)/./test/functional/data/wallets/high_minversion/ error code: -4 error message: Wallet loading failed. ``` gives me a GUI popup and no reason why loading the wallet failed. After this pull request: ``` $ ./src/bitcoin-cli loadwallet $(pwd)/./test/functional/data/wallets/high_minversion/ error code: -4 error message: Wallet loading failed: Error loading /home/marco/workspace/btc_bitcoin_core/./test/functional/data/wallets/high_minversion/wallet.dat: Wallet requires newer version of Bitcoin Core ACKs for top commit: laanwj: Code review ACK facec1c643105d0ae74b5d32cf33d593f9e82a36 Tree-SHA512: c8274bbb02cfcf71676eeec1e773e51fb3538cf93f82e7cb8536f4716d44ed819cdc162dfc039ac7386a4db381a734cdb27fd32567043a1180c02519fbcba194
| * wallet: Avoid showing GUI popups on RPC errorsMarcoFalke2019-10-081-1/+1
| |
* | Remove unused includespracticalswift2019-10-151-2/+0
|/
* Merge #15588: Log the actual wallet file version and no longer publicly ↵MeshCollider2019-07-271-11/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expose the "version" record 35e60e790f2cd602d1bdd0be835d27f0ba37efa9 Remove ReadVersion and WriteVersion (Andrew Chow) b3d4f6c9619142948ab3d53551b4f3c0d7d73bde Log the actual wallet file version (Andrew Chow) c88e87c3b2be3f97b712107e04285d06dfef3878 Remove nFileVersion from CWalletScanState (Andrew Chow) Pull request description: The wallet file version is stored in the "minversion" record, not the "version" record. However "version" is no longer used anywhere except to record the highest versioned client which has opened a wallet file (which is currently only used to check whether this was most recently opened by a 0.4.0 or 0.5.0rc1 client which had a broken wallet encryption implementation). Furthermore, "version" was logged to the debug.log which is confusing because it is not the actual wallet file version. This PR changes it so that this confusion largely no longer exists. The wallet file version logging is changed to use "minversion" and reading and writing the "version" record is no longer publicly exposed to prevent potential confusion about whether the actual file version is being read or written. Lastly, in the one place it is actually used, the variable name is changed from nFileVersion to last_client to better reflect what that record actually represents. ACKs for top commit: jb55: ACK 35e60e7, I compiled locally as a quick sanity check. ryanofsky: utACK 35e60e790f2cd602d1bdd0be835d27f0ba37efa9. This code still pretty confusing, but a little simpler now. And the previous log statement was really misleading and useless compared to the new one here. meshcollider: Looks good, thanks! utACK 35e60e790f2cd602d1bdd0be835d27f0ba37efa9 Tree-SHA512: f782b2f215d07fbc9b806322bda8085445b81c02b65ca674a8c6a3e1de505a0abd050669afe0ead4778816144a1c18462e13930071cedb7227a058aeb39493f7
| * Remove ReadVersion and WriteVersionAndrew Chow2019-07-221-11/+0
| | | | | | | | | | | | | | | | The "version" record that these functions read and write are not used anywhere in the code except for one place. There is no reason to expose these functions publicly. Furthermore, this avoids potential confusion as developers may mistake these functions for actually reading and writing the wallet version when they do not.
* | scripted-diff: Bump copyright headers in walletMarcoFalke2019-05-061-1/+1
| | | | | | | | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./src/wallet/ -END VERIFY SCRIPT-
* | wallet: Improve log output for errors during loadGlenn Willen2019-03-141-0/+3
|/ | | | | | | | When loading the wallet, display the entire path in error messages, instead of the name (which, for the default wallet, is the empty string.) When an exception occurs during wallet loading, display e.what() if possible, instead of nothing.
* Merge #11911: Free BerkeleyEnvironment instances when not in useWladimir J. van der Laan2019-01-311-15/+19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 14bc2a17dd03ccd89f65a302328763ff22c710c2 Trivial: add doxygen-compatible comments relating to BerkeleyEnvironment (Pierre Rochard) 88b1d956fe3e38f2d2dd805feee9dadb0be9e8a9 Tests: add unit tests for GetWalletEnv (Pierre Rochard) f1f4bb7345b90853ec5037478173601035593d26 Free BerkeleyEnvironment instances when not in use (Russell Yanofsky) Pull request description: Instead of adding BerkeleyEnvironment objects permanently to the g_dbenvs map, use reference counted shared pointers and remove map entries when the last BerkeleyEnvironment reference goes out of scope. This change was requested by @TheBlueMatt and makes code that sets up mock databases cleaner. The mock database environment will now go out of scope and be reset on destruction so there is no need to call BerkeleyEnvironment::Reset() during wallet construction to clear out prior state. This change does affect bitcoin behavior slightly. On startup, instead of same wallet environments staying open throughout VerifyWallets() and OpenWallets() calls, VerifyWallets() will open and close an environment once for each wallet, and OpenWallets() will create its own environment(s) later. Tree-SHA512: 219d77a9e2268298435b86088f998795e059fdab1d2050ba284a9ab8d8a44961c9b5cf96e94ee521688108d23c6db680e3e3a999b8cb2ac2a8590f691d50668b
| * Free BerkeleyEnvironment instances when not in useRussell Yanofsky2018-11-261-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of adding BerkeleyEnvironment objects permanently to the g_dbenvs map, use reference counted shared pointers and remove map entries when the last BerkeleyEnvironment reference goes out of scope. This change was requested by Matt Corallo <[email protected]> and makes code that sets up mock databases cleaner. The mock database environment will now go out of scope and be reset on destruction so there is no need to call BerkeleyEnvironment::Reset() during wallet construction to clear out prior state. This change does affect bitcoin behavior slightly. On startup, instead of same wallet environments staying open throughout VerifyWallets() and OpenWallets() calls, VerifyWallets() will open and close an environment once for each wallet, and OpenWallets() will create its own environment(s) later.
* | Merge #14268: Introduce SafeDbt to handle Dbt with free or memory_cleanse ↵Wladimir J. van der Laan2019-01-161-47/+34
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | raii-style 4a86a0acd9ac3ca392f0584a5fd079a856e5e4ba Make SafeDbt DB_DBT_MALLOC on default initialization (Ben Woosley) 1a9f9f7e5e2e73fb832f5b96ad7e9e57954f3f3c Introduce SafeDbt to handle DB_DBT_MALLOC raii-style (Ben Woosley) 951a44e9cd6cf2b8058244f3f95181c5ba683fdd Drop unused setRange arg to BerkeleyBatch::ReadAtCursor (Ben Woosley) Pull request description: This provides additional exception-safety and case handling for the proper freeing of the associated buffers. Tree-SHA512: a038d728290cdb3905e7d881608052a6675b6425729ceaf7cfe69a6e91c2ee293cdb01e4b695a20963459ffdd9d4a1f9a08b3c07b1b5ba1aa8590a8149f686db
| * Make SafeDbt DB_DBT_MALLOC on default initializationBen Woosley2018-11-241-7/+9
| | | | | | | | | | | | | | If we're constructing the SafeDbt without provided data, it is always malloced, so that is the case we expose. Also run clang-format.
| * Introduce SafeDbt to handle DB_DBT_MALLOC raii-styleBen Woosley2018-11-121-40/+31
| | | | | | | | | | This provides additional exception-safety and case handling for the proper freeing of the associated buffers.
| * Drop unused setRange arg to BerkeleyBatch::ReadAtCursorBen Woosley2018-09-191-8/+2
| |
* | wallet: Create IsDatabaseLoaded functionChun Kuan Lee2018-11-081-0/+1
| |
* | wallet: Add trailing wallet.dat when detecting duplicate wallet if it's a ↵Chun Kuan Lee2018-11-061-0/+3
| | | | | | | | directory.
* | Refactor: Move m_db pointers into BerkeleyDatabaseRussell Yanofsky2018-11-061-1/+15
| | | | | | | | | | | | | | This is a refactoring change that doesn't affect behavior. The motivation behind the change is give BerkeleyEnvironment objects access to BerkeleyDatabase objects so it will be possible to simplify the duplicate wallet check and more reliably avoid opening the same databases twice.
* | scripted-diff: Move util files to separate directory.Jim Posen2018-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmemory.h src/util/memory.h git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp sed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h sed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h sed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h sed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h sed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h sed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am sed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am sed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am sed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am sed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am sed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh sed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh sed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh sed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh sed -i 's/src\\utilstrencodings\.cpp/src\\util\\strencodings\.cpp/' build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj -END VERIFY SCRIPT-
* | wallet: Fix duplicate fileidChun Kuan Lee2018-10-241-0/+7
|/
* Add function to close all Db's and reload the databae environmentAndrew Chow2018-08-091-0/+4
| | | | | | | | | Adds a ReloadDbEnv function to BerkeleyEnvironment in order to close all Db instances, closes the environment, resets it, and then reopens the BerkeleyEnvironment. Also adds a ReloadDbEnv function to BerkeleyDatabase that calls BerkeleyEnvironment's ReloadDbEnv.
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* scripted-diff: Rename wallet database classesRussell Yanofsky2018-04-071-25/+25
| | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; } ren CDBEnv BerkeleyEnvironment ren CDB BerkeleyBatch ren CWalletDBWrapper WalletDatabase ren CWalletDB WalletBatch ren dbw database ren m_dbw m_database ren walletdb batch ren pwalletdb batch ren pwalletdbIn batch_in ren wallet/batch.h wallet/walletdb.h ren pwalletdbEncryption encrypted_batch -END VERIFY SCRIPT-
* Merge #12859: Bugfix: Include <memory> for std::unique_ptrWladimir J. van der Laan2018-04-051-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | a5bca13 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr) Pull request description: Not sure why all these includes were missing, but it's breaking builds for some users: https://bugs.gentoo.org/show_bug.cgi?id=652142 (Added to all files with a reference to `std::unique_ptr`) Tree-SHA512: 8a2c67513ca07b9bb52c34e8a20b15e56f8af2530310d9ee9b0a69694dd05e02e7a3683f14101a2685d457672b56addec591a0bb83900a0eb8e2a43d43200509
| * Bugfix: Include <memory> for std::unique_ptrLuke Dashjr2018-04-021-0/+1
| |