doc: Move wallet lock annotations to header
This commit is contained in:
parent
45f434f44d
commit
faebd2ef40
2 changed files with 33 additions and 34 deletions
|
@ -193,7 +193,7 @@ CPubKey CWallet::GenerateNewKey(WalletBatch &batch, bool internal)
|
||||||
{
|
{
|
||||||
assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
|
assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
|
||||||
assert(!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET));
|
assert(!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET));
|
||||||
AssertLockHeld(cs_wallet); // mapKeyMetadata
|
AssertLockHeld(cs_wallet);
|
||||||
bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
|
bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
|
||||||
|
|
||||||
CKey secret;
|
CKey secret;
|
||||||
|
@ -283,7 +283,7 @@ void CWallet::DeriveNewChildKey(WalletBatch &batch, CKeyMetadata& metadata, CKey
|
||||||
|
|
||||||
bool CWallet::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const CPubKey& pubkey)
|
bool CWallet::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const CPubKey& pubkey)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapKeyMetadata
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
// Make sure we aren't adding private keys to private key disabled wallets
|
// Make sure we aren't adding private keys to private key disabled wallets
|
||||||
assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
|
assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
|
||||||
|
@ -347,14 +347,14 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
|
||||||
|
|
||||||
void CWallet::LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata& meta)
|
void CWallet::LoadKeyMetadata(const CKeyID& keyID, const CKeyMetadata& meta)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapKeyMetadata
|
AssertLockHeld(cs_wallet);
|
||||||
UpdateTimeFirstKey(meta.nCreateTime);
|
UpdateTimeFirstKey(meta.nCreateTime);
|
||||||
mapKeyMetadata[keyID] = meta;
|
mapKeyMetadata[keyID] = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata& meta)
|
void CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata& meta)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // m_script_metadata
|
AssertLockHeld(cs_wallet);
|
||||||
UpdateTimeFirstKey(meta.nCreateTime);
|
UpdateTimeFirstKey(meta.nCreateTime);
|
||||||
m_script_metadata[script_id] = meta;
|
m_script_metadata[script_id] = meta;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ bool CWallet::WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey,
|
||||||
|
|
||||||
void CWallet::UpgradeKeyMetadata()
|
void CWallet::UpgradeKeyMetadata()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapKeyMetadata
|
AssertLockHeld(cs_wallet);
|
||||||
if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_KEY_ORIGIN_METADATA)) {
|
if (IsLocked() || IsWalletFlagSet(WALLET_FLAG_KEY_ORIGIN_METADATA)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ void CWallet::ChainStateFlushed(const CBlockLocator& loc)
|
||||||
|
|
||||||
void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in, bool fExplicit)
|
void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in, bool fExplicit)
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet); // nWalletVersion
|
LOCK(cs_wallet);
|
||||||
if (nWalletVersion >= nVersion)
|
if (nWalletVersion >= nVersion)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in,
|
||||||
|
|
||||||
bool CWallet::SetMaxVersion(int nVersion)
|
bool CWallet::SetMaxVersion(int nVersion)
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet); // nWalletVersion, nWalletMaxVersion
|
LOCK(cs_wallet);
|
||||||
// cannot downgrade below current version
|
// cannot downgrade below current version
|
||||||
if (nWalletVersion > nVersion)
|
if (nWalletVersion > nVersion)
|
||||||
return false;
|
return false;
|
||||||
|
@ -879,7 +879,7 @@ DBErrors CWallet::ReorderTransactions()
|
||||||
|
|
||||||
int64_t CWallet::IncOrderPosNext(WalletBatch* batch)
|
int64_t CWallet::IncOrderPosNext(WalletBatch* batch)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // nOrderPosNext
|
AssertLockHeld(cs_wallet);
|
||||||
int64_t nRet = nOrderPosNext++;
|
int64_t nRet = nOrderPosNext++;
|
||||||
if (batch) {
|
if (batch) {
|
||||||
batch->WriteOrderPosNext(nOrderPosNext);
|
batch->WriteOrderPosNext(nOrderPosNext);
|
||||||
|
@ -2616,7 +2616,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
|
||||||
|
|
||||||
bool CWallet::SignTransaction(CMutableTransaction& tx)
|
bool CWallet::SignTransaction(CMutableTransaction& tx)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapWallet
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
// sign the new tx
|
// sign the new tx
|
||||||
int nIn = 0;
|
int nIn = 0;
|
||||||
|
@ -3230,7 +3230,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
||||||
|
|
||||||
DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
|
DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapWallet
|
AssertLockHeld(cs_wallet);
|
||||||
DBErrors nZapSelectTxRet = WalletBatch(*database, "cr+").ZapSelectTx(vHashIn, vHashOut);
|
DBErrors nZapSelectTxRet = WalletBatch(*database, "cr+").ZapSelectTx(vHashIn, vHashOut);
|
||||||
for (uint256 hash : vHashOut) {
|
for (uint256 hash : vHashOut) {
|
||||||
const auto& it = mapWallet.find(hash);
|
const auto& it = mapWallet.find(hash);
|
||||||
|
@ -3257,7 +3257,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
|
||||||
MarkDirty();
|
MarkDirty();
|
||||||
|
|
||||||
return DBErrors::LOAD_OK;
|
return DBErrors::LOAD_OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||||
|
@ -3377,7 +3376,7 @@ bool CWallet::NewKeyPool()
|
||||||
|
|
||||||
size_t CWallet::KeypoolCountExternalKeys()
|
size_t CWallet::KeypoolCountExternalKeys()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setExternalKeyPool
|
AssertLockHeld(cs_wallet);
|
||||||
return setExternalKeyPool.size() + set_pre_split_keypool.size();
|
return setExternalKeyPool.size() + set_pre_split_keypool.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3641,7 +3640,7 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances(interfaces::Chain:
|
||||||
|
|
||||||
std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // mapWallet
|
AssertLockHeld(cs_wallet);
|
||||||
std::set< std::set<CTxDestination> > groupings;
|
std::set< std::set<CTxDestination> > groupings;
|
||||||
std::set<CTxDestination> grouping;
|
std::set<CTxDestination> grouping;
|
||||||
|
|
||||||
|
@ -3809,25 +3808,25 @@ void CWallet::MarkReserveKeysAsUsed(int64_t keypool_id)
|
||||||
|
|
||||||
void CWallet::LockCoin(const COutPoint& output)
|
void CWallet::LockCoin(const COutPoint& output)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setLockedCoins
|
AssertLockHeld(cs_wallet);
|
||||||
setLockedCoins.insert(output);
|
setLockedCoins.insert(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UnlockCoin(const COutPoint& output)
|
void CWallet::UnlockCoin(const COutPoint& output)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setLockedCoins
|
AssertLockHeld(cs_wallet);
|
||||||
setLockedCoins.erase(output);
|
setLockedCoins.erase(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UnlockAllCoins()
|
void CWallet::UnlockAllCoins()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setLockedCoins
|
AssertLockHeld(cs_wallet);
|
||||||
setLockedCoins.clear();
|
setLockedCoins.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const
|
bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setLockedCoins
|
AssertLockHeld(cs_wallet);
|
||||||
COutPoint outpt(hash, n);
|
COutPoint outpt(hash, n);
|
||||||
|
|
||||||
return (setLockedCoins.count(outpt) > 0);
|
return (setLockedCoins.count(outpt) > 0);
|
||||||
|
@ -3835,7 +3834,7 @@ bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const
|
||||||
|
|
||||||
void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
|
void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // setLockedCoins
|
AssertLockHeld(cs_wallet);
|
||||||
for (std::set<COutPoint>::iterator it = setLockedCoins.begin();
|
for (std::set<COutPoint>::iterator it = setLockedCoins.begin();
|
||||||
it != setLockedCoins.end(); it++) {
|
it != setLockedCoins.end(); it++) {
|
||||||
COutPoint outpt = (*it);
|
COutPoint outpt = (*it);
|
||||||
|
@ -3846,7 +3845,7 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
|
||||||
/** @} */ // end of Actions
|
/** @} */ // end of Actions
|
||||||
|
|
||||||
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t>& mapKeyBirth) const {
|
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t>& mapKeyBirth) const {
|
||||||
AssertLockHeld(cs_wallet); // mapKeyMetadata
|
AssertLockHeld(cs_wallet);
|
||||||
mapKeyBirth.clear();
|
mapKeyBirth.clear();
|
||||||
|
|
||||||
// get birth times for keys with metadata
|
// get birth times for keys with metadata
|
||||||
|
@ -4125,7 +4124,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int prev_version = walletInstance->nWalletVersion;
|
int prev_version = walletInstance->GetVersion();
|
||||||
if (gArgs.GetBoolArg("-upgradewallet", fFirstRun))
|
if (gArgs.GetBoolArg("-upgradewallet", fFirstRun))
|
||||||
{
|
{
|
||||||
int nMaxVersion = gArgs.GetArg("-upgradewallet", 0);
|
int nMaxVersion = gArgs.GetArg("-upgradewallet", 0);
|
||||||
|
@ -4150,7 +4149,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
||||||
LOCK(walletInstance->cs_wallet);
|
LOCK(walletInstance->cs_wallet);
|
||||||
|
|
||||||
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
||||||
int max_version = walletInstance->nWalletVersion;
|
int max_version = walletInstance->GetVersion();
|
||||||
if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
||||||
chain.initError(_("Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use -upgradewallet=169900 or -upgradewallet with no version specified."));
|
chain.initError(_("Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use -upgradewallet=169900 or -upgradewallet with no version specified."));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -648,7 +648,7 @@ private:
|
||||||
WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr;
|
WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr;
|
||||||
|
|
||||||
//! the current wallet version: clients below this version are not able to load the wallet
|
//! the current wallet version: clients below this version are not able to load the wallet
|
||||||
int nWalletVersion = FEATURE_BASE;
|
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
|
||||||
|
|
||||||
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
|
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
|
||||||
int nWalletMaxVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
|
int nWalletMaxVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
|
||||||
|
@ -700,9 +700,9 @@ private:
|
||||||
/* HD derive new child key (on internal or external chain) */
|
/* HD derive new child key (on internal or external chain) */
|
||||||
void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secret, bool internal = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
std::set<int64_t> setInternalKeyPool;
|
std::set<int64_t> setInternalKeyPool GUARDED_BY(cs_wallet);
|
||||||
std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_wallet);
|
std::set<int64_t> setExternalKeyPool GUARDED_BY(cs_wallet);
|
||||||
std::set<int64_t> set_pre_split_keypool;
|
std::set<int64_t> set_pre_split_keypool GUARDED_BY(cs_wallet);
|
||||||
int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0;
|
int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0;
|
||||||
std::map<CKeyID, int64_t> m_pool_key_to_index;
|
std::map<CKeyID, int64_t> m_pool_key_to_index;
|
||||||
std::atomic<uint64_t> m_wallet_flags{0};
|
std::atomic<uint64_t> m_wallet_flags{0};
|
||||||
|
@ -1065,7 +1065,7 @@ public:
|
||||||
|
|
||||||
unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
|
unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet); // set{Ex,In}ternalKeyPool
|
AssertLockHeld(cs_wallet);
|
||||||
return setInternalKeyPool.size() + setExternalKeyPool.size();
|
return setInternalKeyPool.size() + setExternalKeyPool.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue