aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-01-06 10:33:19 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-01-06 10:34:01 +0100
commit7aedb914762eaf25f954790c50f9561103fee4b8 (patch)
treee9b693e5f7da9936da44f8d204456d7d0ea671be /src/wallet.h
parentab086e0bd39b6d010c040c9bf4d781400fc7b9f8 (diff)
parent012ca1c9e4f21e0414f965cb812ecb1f2ddb4f67 (diff)
downloadbitcoin-7aedb914762eaf25f954790c50f9561103fee4b8.tar.xz
Merge pull request #3401
012ca1c LoadWallet: acquire cs_wallet mutex before clearing setKeyPool (Wladimir J. van der Laan) 9569168 Document cs_wallet lock and add AssertLockHeld (Wladimir J. van der Laan) 19a5676 Use mutex pointer instead of name for AssertLockHeld (Wladimir J. van der Laan)
Diffstat (limited to 'src/wallet.h')
-rw-r--r--src/wallet.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/wallet.h b/src/wallet.h
index 99f6293b1e..e4452a3093 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -105,6 +105,11 @@ private:
int64_t nLastResend;
public:
+ /// Main wallet lock.
+ /// This lock protects all the fields added by CWallet
+ /// except for:
+ /// fFileBacked (immutable after instantiation)
+ /// strWalletFile (immutable after instantiation)
mutable CCriticalSection cs_wallet;
bool fFileBacked;
@@ -154,10 +159,11 @@ public:
int64_t nTimeFirstKey;
// check whether we are allowed to upgrade (or already support) to the named feature
- bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; }
+ bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const;
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
+
bool IsLockedCoin(uint256 hash, unsigned int n) const;
void LockCoin(COutPoint& output);
void UnlockCoin(COutPoint& output);
@@ -174,7 +180,7 @@ public:
// Load metadata (used by LoadWallet)
bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata);
- bool LoadMinVersion(int nVersion) { nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
+ bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
// Adds an encrypted key to the store, and saves it to disk.
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
@@ -323,6 +329,7 @@ public:
unsigned int GetKeyPoolSize()
{
+ AssertLockHeld(cs_wallet); // setKeyPool
return setKeyPool.size();
}
@@ -335,7 +342,7 @@ public:
bool SetMaxVersion(int nVersion);
// get the current wallet format (the oldest client version guaranteed to understand this wallet)
- int GetVersion() { return nWalletVersion; }
+ int GetVersion() { AssertLockHeld(cs_wallet); return nWalletVersion; }
/** Address book entry changed.
* @note called with lock cs_wallet held.