@@ -35,6 +35,7 @@ struct CompareValueOnly
35
35
36
36
CPubKey CWallet::GenerateNewKey ()
37
37
{
38
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
38
39
bool fCompressed = CanSupportFeature (FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
39
40
40
41
RandAddSeedPerfmon ();
@@ -60,6 +61,7 @@ CPubKey CWallet::GenerateNewKey()
60
61
61
62
bool CWallet::AddKeyPubKey (const CKey& secret, const CPubKey &pubkey)
62
63
{
64
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
63
65
if (!CCryptoKeyStore::AddKeyPubKey (secret, pubkey))
64
66
return false ;
65
67
if (!fFileBacked )
@@ -95,6 +97,7 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
95
97
96
98
bool CWallet::LoadKeyMetadata (const CPubKey &pubkey, const CKeyMetadata &meta)
97
99
{
100
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
98
101
if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey))
99
102
nTimeFirstKey = meta.nCreateTime ;
100
103
@@ -202,6 +205,7 @@ class CCorruptAddress
202
205
203
206
bool CWallet::SetMinVersion (enum WalletFeature nVersion, CWalletDB* pwalletdbIn, bool fExplicit )
204
207
{
208
+ AssertLockHeld (cs_wallet); // nWalletVersion
205
209
if (nWalletVersion >= nVersion)
206
210
return true ;
207
211
@@ -235,6 +239,7 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
235
239
236
240
bool CWallet::SetMaxVersion (int nVersion)
237
241
{
242
+ AssertLockHeld (cs_wallet); // nWalletVersion, nWalletMaxVersion
238
243
// cannot downgrade below current version
239
244
if (nWalletVersion > nVersion)
240
245
return false ;
@@ -327,6 +332,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
327
332
328
333
int64_t CWallet::IncOrderPosNext (CWalletDB *pwalletdb)
329
334
{
335
+ AssertLockHeld (cs_wallet); // nOrderPosNext
330
336
int64_t nRet = nOrderPosNext++;
331
337
if (pwalletdb) {
332
338
pwalletdb->WriteOrderPosNext (nOrderPosNext);
@@ -338,6 +344,7 @@ int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
338
344
339
345
CWallet::TxItems CWallet::OrderedTxItems (std::list<CAccountingEntry>& acentries, std::string strAccount)
340
346
{
347
+ AssertLockHeld (cs_wallet); // mapWallet
341
348
CWalletDB walletdb (strWalletFile);
342
349
343
350
// First: get all CWalletTx and CAccountingEntry into a sorted-by-order multimap.
@@ -1492,6 +1499,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
1492
1499
{
1493
1500
if (CDB::Rewrite (strWalletFile, " \x04 pool" ))
1494
1501
{
1502
+ LOCK (cs_wallet);
1495
1503
setKeyPool.clear ();
1496
1504
// Note: can't top-up keypool here, because wallet is locked.
1497
1505
// User will be prompted to unlock wallet the next operation
@@ -1509,6 +1517,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
1509
1517
1510
1518
bool CWallet::SetAddressBook (const CTxDestination& address, const string& strName, const string& strPurpose)
1511
1519
{
1520
+ AssertLockHeld (cs_wallet); // mapAddressBook
1512
1521
std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find (address);
1513
1522
mapAddressBook[address].name = strName;
1514
1523
if (!strPurpose.empty ()) /* update purpose only if requested */
@@ -1525,6 +1534,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
1525
1534
1526
1535
bool CWallet::DelAddressBook (const CTxDestination& address)
1527
1536
{
1537
+ AssertLockHeld (cs_wallet); // mapAddressBook
1528
1538
mapAddressBook.erase (address);
1529
1539
NotifyAddressBookChanged (this , address, " " , ::IsMine (*this , address), " " , CT_DELETED);
1530
1540
if (!fFileBacked )
@@ -1738,6 +1748,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
1738
1748
1739
1749
set< set<CTxDestination> > CWallet::GetAddressGroupings ()
1740
1750
{
1751
+ AssertLockHeld (cs_wallet); // mapWallet
1741
1752
set< set<CTxDestination> > groupings;
1742
1753
set<CTxDestination> grouping;
1743
1754
@@ -1830,6 +1841,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
1830
1841
1831
1842
set<CTxDestination> CWallet::GetAccountAddresses (string strAccount) const
1832
1843
{
1844
+ AssertLockHeld (cs_wallet); // mapWallet
1833
1845
set<CTxDestination> result;
1834
1846
BOOST_FOREACH (const PAIRTYPE (CTxDestination, CAddressBookData)& item, mapAddressBook)
1835
1847
{
@@ -1911,28 +1923,33 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
1911
1923
1912
1924
void CWallet::LockCoin (COutPoint& output)
1913
1925
{
1926
+ AssertLockHeld (cs_wallet); // setLockedCoins
1914
1927
setLockedCoins.insert (output);
1915
1928
}
1916
1929
1917
1930
void CWallet::UnlockCoin (COutPoint& output)
1918
1931
{
1932
+ AssertLockHeld (cs_wallet); // setLockedCoins
1919
1933
setLockedCoins.erase (output);
1920
1934
}
1921
1935
1922
1936
void CWallet::UnlockAllCoins ()
1923
1937
{
1938
+ AssertLockHeld (cs_wallet); // setLockedCoins
1924
1939
setLockedCoins.clear ();
1925
1940
}
1926
1941
1927
1942
bool CWallet::IsLockedCoin (uint256 hash, unsigned int n) const
1928
1943
{
1944
+ AssertLockHeld (cs_wallet); // setLockedCoins
1929
1945
COutPoint outpt (hash, n);
1930
1946
1931
1947
return (setLockedCoins.count (outpt) > 0 );
1932
1948
}
1933
1949
1934
1950
void CWallet::ListLockedCoins (std::vector<COutPoint>& vOutpts)
1935
1951
{
1952
+ AssertLockHeld (cs_wallet); // setLockedCoins
1936
1953
for (std::set<COutPoint>::iterator it = setLockedCoins.begin ();
1937
1954
it != setLockedCoins.end (); it++) {
1938
1955
COutPoint outpt = (*it);
@@ -1941,6 +1958,7 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts)
1941
1958
}
1942
1959
1943
1960
void CWallet::GetKeyBirthTimes (std::map<CKeyID, int64_t > &mapKeyBirth) const {
1961
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
1944
1962
mapKeyBirth.clear ();
1945
1963
1946
1964
// get birth times for keys with metadata
0 commit comments