@@ -33,6 +33,7 @@ struct CompareValueOnly
33
33
34
34
CPubKey CWallet::GenerateNewKey ()
35
35
{
36
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
36
37
bool fCompressed = CanSupportFeature (FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
37
38
38
39
RandAddSeedPerfmon ();
@@ -58,6 +59,7 @@ CPubKey CWallet::GenerateNewKey()
58
59
59
60
bool CWallet::AddKeyPubKey (const CKey& secret, const CPubKey &pubkey)
60
61
{
62
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
61
63
if (!CCryptoKeyStore::AddKeyPubKey (secret, pubkey))
62
64
return false ;
63
65
if (!fFileBacked )
@@ -93,6 +95,7 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
93
95
94
96
bool CWallet::LoadKeyMetadata (const CPubKey &pubkey, const CKeyMetadata &meta)
95
97
{
98
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
96
99
if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey))
97
100
nTimeFirstKey = meta.nCreateTime ;
98
101
@@ -200,6 +203,7 @@ class CCorruptAddress
200
203
201
204
bool CWallet::SetMinVersion (enum WalletFeature nVersion, CWalletDB* pwalletdbIn, bool fExplicit )
202
205
{
206
+ AssertLockHeld (cs_wallet); // nWalletVersion
203
207
if (nWalletVersion >= nVersion)
204
208
return true ;
205
209
@@ -233,6 +237,7 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
233
237
234
238
bool CWallet::SetMaxVersion (int nVersion)
235
239
{
240
+ AssertLockHeld (cs_wallet); // nWalletVersion, nWalletMaxVersion
236
241
// cannot downgrade below current version
237
242
if (nWalletVersion > nVersion)
238
243
return false ;
@@ -325,6 +330,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
325
330
326
331
int64_t CWallet::IncOrderPosNext (CWalletDB *pwalletdb)
327
332
{
333
+ AssertLockHeld (cs_wallet); // nOrderPosNext
328
334
int64_t nRet = nOrderPosNext++;
329
335
if (pwalletdb) {
330
336
pwalletdb->WriteOrderPosNext (nOrderPosNext);
@@ -336,6 +342,7 @@ int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
336
342
337
343
CWallet::TxItems CWallet::OrderedTxItems (std::list<CAccountingEntry>& acentries, std::string strAccount)
338
344
{
345
+ AssertLockHeld (cs_wallet); // mapWallet
339
346
CWalletDB walletdb (strWalletFile);
340
347
341
348
// First: get all CWalletTx and CAccountingEntry into a sorted-by-order multimap.
@@ -1482,6 +1489,7 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nV
1482
1489
1483
1490
DBErrors CWallet::LoadWallet (bool & fFirstRunRet )
1484
1491
{
1492
+ AssertLockHeld (cs_wallet); // setKeyPool
1485
1493
if (!fFileBacked )
1486
1494
return DB_LOAD_OK;
1487
1495
fFirstRunRet = false ;
@@ -1507,6 +1515,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
1507
1515
1508
1516
bool CWallet::SetAddressBook (const CTxDestination& address, const string& strName, const string& strPurpose)
1509
1517
{
1518
+ AssertLockHeld (cs_wallet); // mapAddressBook
1510
1519
std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find (address);
1511
1520
mapAddressBook[address].name = strName;
1512
1521
if (!strPurpose.empty ()) /* update purpose only if requested */
@@ -1523,6 +1532,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
1523
1532
1524
1533
bool CWallet::DelAddressBook (const CTxDestination& address)
1525
1534
{
1535
+ AssertLockHeld (cs_wallet); // mapAddressBook
1526
1536
mapAddressBook.erase (address);
1527
1537
NotifyAddressBookChanged (this , address, " " , ::IsMine (*this , address), " " , CT_DELETED);
1528
1538
if (!fFileBacked )
@@ -1736,6 +1746,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
1736
1746
1737
1747
set< set<CTxDestination> > CWallet::GetAddressGroupings ()
1738
1748
{
1749
+ AssertLockHeld (cs_wallet); // mapWallet
1739
1750
set< set<CTxDestination> > groupings;
1740
1751
set<CTxDestination> grouping;
1741
1752
@@ -1828,6 +1839,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
1828
1839
1829
1840
set<CTxDestination> CWallet::GetAccountAddresses (string strAccount) const
1830
1841
{
1842
+ AssertLockHeld (cs_wallet); // mapWallet
1831
1843
set<CTxDestination> result;
1832
1844
BOOST_FOREACH (const PAIRTYPE (CTxDestination, CAddressBookData)& item, mapAddressBook)
1833
1845
{
@@ -1909,28 +1921,33 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
1909
1921
1910
1922
void CWallet::LockCoin (COutPoint& output)
1911
1923
{
1924
+ AssertLockHeld (cs_wallet); // setLockedCoins
1912
1925
setLockedCoins.insert (output);
1913
1926
}
1914
1927
1915
1928
void CWallet::UnlockCoin (COutPoint& output)
1916
1929
{
1930
+ AssertLockHeld (cs_wallet); // setLockedCoins
1917
1931
setLockedCoins.erase (output);
1918
1932
}
1919
1933
1920
1934
void CWallet::UnlockAllCoins ()
1921
1935
{
1936
+ AssertLockHeld (cs_wallet); // setLockedCoins
1922
1937
setLockedCoins.clear ();
1923
1938
}
1924
1939
1925
1940
bool CWallet::IsLockedCoin (uint256 hash, unsigned int n) const
1926
1941
{
1942
+ AssertLockHeld (cs_wallet); // setLockedCoins
1927
1943
COutPoint outpt (hash, n);
1928
1944
1929
1945
return (setLockedCoins.count (outpt) > 0 );
1930
1946
}
1931
1947
1932
1948
void CWallet::ListLockedCoins (std::vector<COutPoint>& vOutpts)
1933
1949
{
1950
+ AssertLockHeld (cs_wallet); // setLockedCoins
1934
1951
for (std::set<COutPoint>::iterator it = setLockedCoins.begin ();
1935
1952
it != setLockedCoins.end (); it++) {
1936
1953
COutPoint outpt = (*it);
@@ -1939,6 +1956,7 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts)
1939
1956
}
1940
1957
1941
1958
void CWallet::GetKeyBirthTimes (std::map<CKeyID, int64_t > &mapKeyBirth) const {
1959
+ AssertLockHeld (cs_wallet); // mapKeyMetadata
1942
1960
mapKeyBirth.clear ();
1943
1961
1944
1962
// get birth times for keys with metadata
0 commit comments