mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-24 13:59:38 +02:00
wallet: ensure that the passphrase is not deleted from memory when being used to rescan
`m_relock_mutex` is introduced so that the passphrase is not deleted from memory when the timeout provided in `walletpassphrase` is up, but the wallet is still rescanning.
This commit is contained in:
@@ -551,7 +551,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||
bool fWasLocked = IsLocked();
|
||||
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
LOCK2(m_relock_mutex, cs_wallet);
|
||||
Lock();
|
||||
|
||||
CCrypter crypter;
|
||||
@@ -786,7 +786,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
||||
return false;
|
||||
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
LOCK2(m_relock_mutex, cs_wallet);
|
||||
mapMasterKeys[++nMasterKeyMaxID] = kMasterKey;
|
||||
WalletBatch* encrypted_batch = new WalletBatch(GetDatabase());
|
||||
if (!encrypted_batch->TxnBegin()) {
|
||||
@@ -3407,7 +3407,7 @@ bool CWallet::Lock()
|
||||
return false;
|
||||
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
LOCK2(m_relock_mutex, cs_wallet);
|
||||
if (!vMasterKey.empty()) {
|
||||
memory_cleanse(vMasterKey.data(), vMasterKey.size() * sizeof(decltype(vMasterKey)::value_type));
|
||||
vMasterKey.clear();
|
||||
|
||||
Reference in New Issue
Block a user