Commit Graph

55 Commits

Author SHA1 Message Date
Wladimir J. van der Laan 33232810dc wallet: CWalletDB CDB composition not inheritance
CWalletDB now contains a CDB instead of inheriting from it.

This makes it easier to replace the internal transaction with a different
database, without leaking through internals.
2017-04-20 17:55:01 +02:00
Wladimir J. van der Laan 71afe3c099 wallet: Introduce database handle wrapper
Abstract database handle from explicit strFilename into
CWalletDBWrapper.

Also move CWallet::Backup to db.cpp - as it deals with representation
details this is a database specific operation.
2017-04-20 17:15:30 +02:00
Wladimir J. van der Laan bac5c9cf64 Replace uses of boost::filesystem with fs
Step two in abstracting away boost::filesystem.

To repeat this, simply run:
```
git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g'
```
2017-04-03 12:32:32 +02:00
Wladimir J. van der Laan 7d5172d354 Replace includes of boost/filesystem.h with fs.h
This is step one in abstracting the use of boost::filesystem.
2017-04-03 12:32:32 +02:00
Gregory Maxwell 6b3bb3d9ba Change LogAcceptCategory to use uint32_t rather than sets of strings.
This changes the logging categories to boolean flags instead of strings.

This simplifies the acceptance testing by avoiding accessing a scoped
 static thread local pointer to a thread local set of strings.  It
 eliminates the only use of boost::thread_specific_ptr outside of
 lockorder debugging.

This change allows log entries to be directed to multiple categories
 and makes it easy to change the logging flags at runtime (e.g. via
 an RPC, though that isn't done by this commit.)

It also eliminates the fDebug global.

Configuration of unknown logging categories now produces a warning.
2017-04-01 18:53:29 +00:00
Karl-Johan Alm 8a5228197c
Refactor: Remove using namespace <xxx> from wallet/ 2017-03-08 08:46:59 -08:00
Matt Corallo 0235be1e7a Rename FlushWalletDB -> CompactWalletDB, add function description 2017-03-06 18:35:20 -05:00
Matt Corallo 735d9b5362 Use CScheduler for wallet flushing, remove ThreadFlushWalletDB 2017-03-06 18:35:19 -05:00
Jonas Schnelli 7184e25c80
[Wallet] refactor CWallet/CWalletDB/CDB
Try to hide CDB/bitdb behinde CWalletDB.
Prepare for full wallet database abstraction.
2017-03-06 11:30:24 +01:00
Wladimir J. van der Laan 65d90f585a
Merge #9143: Refactor ZapWalletTxes to avoid layer violations
0165a56 Refactor ZapWalletTxes to avoid layer vialotions (Jonas Schnelli)

Tree-SHA512: 51e3abbb866185817d14d685a65cb1070a7a60aa3db692670f3a5fdd328aad59afa765c5a6b13d9e8f6d219e735487f8c87998f2fb38fdd911c1fe19bea373b9
2017-03-02 11:32:34 +01:00
Russell Yanofsky 07afcd6379 Add missing cs_wallet lock that triggers new lock held assertion
A new AssertLockHeld(cs_wallet) call was added in commit a58370e
"Dedup nTimeFirstKey update logic" (part of PR #9108).

The lock held assertion will fail when loading prexisting wallets files from
before the #9108 merge that have watch-only keys.
2017-02-15 17:01:30 -05:00
Russell Yanofsky a80f98b1c7 Use importmulti timestamp when importing watch only keys
When importing a watch-only address over importmulti with a specific timestamp,
the wallet's nTimeFirstKey is currently set to 1. After this change, the
provided timestamp will be used and stored as metadata associated with
watch-only key. This can improve wallet performance because it can avoid the
need to scan the entire blockchain for watch only addresses when timestamps are
provided.

Also adds timestamp to validateaddress return value (needed for tests).

Fixes #9034.
2017-02-10 16:11:19 -05:00
Russell Yanofsky a58370e6a2 Dedup nTimeFirstKey update logic
Also make nTimeFirstKey member variable private.

This is just a cleanup change, it doesn't change behavior in any significant
way.
2017-02-10 15:49:00 -05:00
Wladimir J. van der Laan 02464da5e4
Merge #9227: Make nWalletDBUpdated atomic to avoid a potential race.
d63ff62 Make nWalletDBUpdated atomic to avoid a potential race. (Patrick Strateman)
2017-02-06 16:14:17 +01:00
Jonas Schnelli 0165a56f20
Refactor ZapWalletTxes to avoid layer vialotions 2017-01-24 14:25:42 +01:00
Wladimir J. van der Laan c0ddd32bf6
Merge #9450: Increment MIT licence copyright header year on files modified in 2016
27765b6 Increment MIT Licence copyright header year on files modified in 2016 (isle2983)
2017-01-04 12:09:05 +01:00
Pieter Wuille 2a524b8e8f
Merge #8776: Wallet refactoring leading up to multiwallet
5394b39 Wallet: Split main logic from InitLoadWallet into CreateWalletFromFile (Luke Dashjr)
fb0c934 Wallet: Let the interval-flushing thread figure out the filename (Luke Dashjr)
2017-01-03 14:11:11 -08:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Patrick Strateman d63ff6265b Make nWalletDBUpdated atomic to avoid a potential race. 2016-12-21 13:49:48 -08:00
Matt Corallo 76faa3cdfe Rename the remaining main.{h,cpp} to validation.{h,cpp} 2016-12-02 09:42:51 -08:00
Luke Dashjr fb0c934d1b Wallet: Let the interval-flushing thread figure out the filename 2016-11-11 11:35:49 +00:00
Patrick Strateman 86029e72c9 Move CWalletDB::ReorderTransactions to CWallet 2016-10-30 02:15:49 -07:00
Wladimir J. van der Laan 6f939c9080
Merge #8629: C++11: s/boost::scoped_ptr/std::unique_ptr/
cdd79eb C++11: s/boost::scoped_ptr/std::unique_ptr/ (Jorge Timón)
2016-09-02 09:56:33 +02:00
Jorge Timón cdd79eb70f C++11: s/boost::scoped_ptr/std::unique_ptr/ 2016-09-01 19:05:07 +02:00
Pavel Janík b175cb755b Do not shadow variables. 2016-08-31 16:16:05 +02:00
Pieter Wuille 01680195f8
Merge #8564: [Wallet] remove unused code/conditions in ReadAtCursor
beef966 [Wallet] remove unused code/conditions in ReadAtCursor (Jonas Schnelli)
2016-08-29 16:16:23 +02:00
Wladimir J. van der Laan f9167003d9
Merge #8445: Move CWallet::setKeyPool to private section of CWallet.
8680d3a Move wallet initialization logic from AppInit2 to CWallet::InitLoadWallet (Patrick Strateman)
e86eb71 Move CWallet::setKeyPool to private section of CWallet (Patrick Strateman)
2016-08-24 10:33:16 +02:00
Jonas Schnelli beef966e36
[Wallet] remove unused code/conditions in ReadAtCursor 2016-08-23 15:36:23 +02:00
MarcoFalke fa785d1211 Use __func__ to get function name for output printing 2016-08-19 18:59:00 +02:00
Patrick Strateman e86eb71604 Move CWallet::setKeyPool to private section of CWallet 2016-08-17 15:24:57 -07:00
Patrick Strateman 00f09c920c Split CWallet::AddToWallet into AddToWallet and LoadToWallet.
This removes the fFromLoadWallet flag in AddToWallet.  These were already
effectively two methods.
2016-07-29 17:04:14 -07:00
Jonas Schnelli b993671921
[Wallet] keep HD seed during salvagewallet 2016-07-09 12:58:03 +02:00
Jonas Schnelli f19025106d
[Wallet] Add simplest BIP32/deterministic key generation implementation 2016-05-31 14:47:00 +02:00
Patrick Strateman 380498aba4 Move BackupWallet to CWallet::BackupWallet 2016-05-16 17:48:25 -07:00
Patrick Strateman 0fd599767d Fix insanity of CWalletDB::WriteTx and CWalletTx::WriteToDisk 2016-05-09 00:20:17 -07:00
instagibbs f1bb13c93d Added companion removeprunedfunds call. 2016-03-23 10:40:38 -04:00
MarcoFalke fa19b18c63 [wallet] Move hardcoded file name out of log messages 2016-03-14 13:54:05 +01:00
Cory Fields c0cf48d1ac c++11: add scoped enum fallbacks to CPPFLAGS rather than defining them locally
Due to include ordering, defining in one place was not enough to ensure correct
usage. Use global defines so that we don't have to worry abou this ordering.

Also add a comment in configure about the test.
2016-01-08 13:32:00 -05:00
Wladimir J. van der Laan d964b5bb1a
Merge pull request #7229
fa33d97 [walletdb] Add missing LOCK() in Recover() for dummyWallet (MarcoFalke)
fa14d99 [qa] check if wallet or blochchain maintenance changes the balance (MarcoFalke)
fa0765d [qa] Cleanup wallet.py test (MarcoFalke)
2016-01-07 09:17:11 +01:00
Cory Fields 76ac35f36d c++11: detect and correct for boost builds with an incompatible abi
This is ugly, but temporary. boost::filesystem will likely be dropped soon
after c++11 is enabled. Otherwise, we could simply roll our own copy_file. I've
fixed this at the buildsystem level for now in order to avoid mixing in
functional changes.

Explanation:
If boost (prior to 1.57) was built without c++11, it emulated scoped enums
using c++98 constructs. Unfortunately, this implementation detail leaked into
the abi. This was fixed in 1.57.

When building against that installed version using c++11, the headers pick up
on the native c++11 scoped enum support and enable it, however it will fail to
link. This can be worked around by disabling c++11 scoped enums if linking will
fail.

Add an autoconf test to determine incompatibility. At build-time, if native
enums are being used (a c++11 build), and force-disabling them causes a
successful link, we can be sure that there's an incompatibility and enable the
work-around.
2016-01-05 17:17:29 -05:00
MarcoFalke fa33d9740c [walletdb] Add missing LOCK() in Recover() for dummyWallet 2015-12-19 14:26:46 +01:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Wladimir J. van der Laan 327291af02
Merge pull request #6914
114b581 Prevector type (Pieter Wuille)
2015-12-01 10:22:14 +01:00
Luke Dashjr b966aa836a Constrain constant values to a single location in code 2015-11-28 18:47:29 +01:00
Luke Dashjr 3e7c89196c Optimisation: Store transaction list order in memory rather than compute it every need
Huge performance improvement (450%) for zapwallettxes
2015-11-21 01:48:25 +00:00
Pieter Wuille 114b5812f6 Prevector type 2015-11-13 18:15:20 +01:00
Gregory Maxwell 30d9662bd7 Reject invalid pubkeys when reading ckey items from the wallet.
This makes the behavior more consistent with key objects and will
 reject some corrupted pubkeys (e.g. zero length).
2015-10-29 18:24:49 +00:00
Pieter Wuille 391dff16fe Do not store Merkle branches in the wallet.
Assume that when a wallet transaction has a valid block hash and transaction position
in it, the transaction is actually there. We're already trusting wallet data in a
much more fundamental way anyway.

To prevent backward compatibility issues, a new record is used for storing the
block locator in the wallet. Old wallets will see a wallet file synchronized up
to the genesis block, and rescan automatically.
2015-09-22 18:51:07 +02:00
Jorge Timón 60c8bac77c Includes: Cleanup around net main and wallet
-Move from .h to .cpp: in main, net and wallet
-Remove unnecessary #include "main.h"
-Cleanup some wallet files includes
2015-07-23 21:10:26 +02:00
Wladimir J. van der Laan c7c9af381c
Merge pull request #5669
da29ecb Consensus: MOVEONLY: Move CValidationState from main consensus/validation (jtimon)
27afcd8 Consensus: Refactor: Decouple CValidationState from main::AbortNode() (Cory Fields)
2015-05-27 15:00:02 +02:00