@@ -614,16 +614,16 @@ static bool DecryptMasterKey(const SecureString& wallet_passphrase, const CMaste
614
614
615
615
bool CWallet::Unlock (const SecureString& strWalletPassphrase)
616
616
{
617
- CKeyingMaterial _vMasterKey ;
617
+ CKeyingMaterial plain_master_key ;
618
618
619
619
{
620
620
LOCK (cs_wallet);
621
- for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
621
+ for (const auto & [_, master_key] : mapMasterKeys)
622
622
{
623
- if (!DecryptMasterKey (strWalletPassphrase, pMasterKey. second , _vMasterKey )) {
623
+ if (!DecryptMasterKey (strWalletPassphrase, master_key, plain_master_key )) {
624
624
continue ; // try another master key
625
625
}
626
- if (Unlock (_vMasterKey )) {
626
+ if (Unlock (plain_master_key )) {
627
627
// Now that we've unlocked, upgrade the key metadata
628
628
UpgradeKeyMetadata ();
629
629
// Now that we've unlocked, upgrade the descriptor cache
@@ -643,20 +643,20 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
643
643
LOCK2 (m_relock_mutex, cs_wallet);
644
644
Lock ();
645
645
646
- CKeyingMaterial _vMasterKey ;
647
- for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
646
+ CKeyingMaterial plain_master_key ;
647
+ for (auto & [master_key_id, master_key] : mapMasterKeys)
648
648
{
649
- if (!DecryptMasterKey (strOldWalletPassphrase, pMasterKey. second , _vMasterKey )) {
649
+ if (!DecryptMasterKey (strOldWalletPassphrase, master_key, plain_master_key )) {
650
650
return false ;
651
651
}
652
- if (Unlock (_vMasterKey ))
652
+ if (Unlock (plain_master_key ))
653
653
{
654
- if (!EncryptMasterKey (strNewWalletPassphrase, _vMasterKey, pMasterKey. second )) {
654
+ if (!EncryptMasterKey (strNewWalletPassphrase, plain_master_key, master_key )) {
655
655
return false ;
656
656
}
657
- WalletLogPrintf (" Wallet passphrase changed to an nDeriveIterations of %i\n " , pMasterKey. second .nDeriveIterations );
657
+ WalletLogPrintf (" Wallet passphrase changed to an nDeriveIterations of %i\n " , master_key .nDeriveIterations );
658
658
659
- WalletBatch (GetDatabase ()).WriteMasterKey (pMasterKey. first , pMasterKey. second );
659
+ WalletBatch (GetDatabase ()).WriteMasterKey (master_key_id, master_key );
660
660
if (fWasLocked )
661
661
Lock ();
662
662
return true ;
@@ -831,35 +831,35 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
831
831
if (IsCrypted ())
832
832
return false ;
833
833
834
- CKeyingMaterial _vMasterKey ;
834
+ CKeyingMaterial plain_master_key ;
835
835
836
- _vMasterKey .resize (WALLET_CRYPTO_KEY_SIZE);
837
- GetStrongRandBytes (_vMasterKey );
836
+ plain_master_key .resize (WALLET_CRYPTO_KEY_SIZE);
837
+ GetStrongRandBytes (plain_master_key );
838
838
839
- CMasterKey kMasterKey ;
839
+ CMasterKey master_key ;
840
840
841
- kMasterKey .vchSalt .resize (WALLET_CRYPTO_SALT_SIZE);
842
- GetStrongRandBytes (kMasterKey .vchSalt );
841
+ master_key .vchSalt .resize (WALLET_CRYPTO_SALT_SIZE);
842
+ GetStrongRandBytes (master_key .vchSalt );
843
843
844
- if (!EncryptMasterKey (strWalletPassphrase, _vMasterKey, kMasterKey )) {
844
+ if (!EncryptMasterKey (strWalletPassphrase, plain_master_key, master_key )) {
845
845
return false ;
846
846
}
847
- WalletLogPrintf (" Encrypting Wallet with an nDeriveIterations of %i\n " , kMasterKey .nDeriveIterations );
847
+ WalletLogPrintf (" Encrypting Wallet with an nDeriveIterations of %i\n " , master_key .nDeriveIterations );
848
848
849
849
{
850
850
LOCK2 (m_relock_mutex, cs_wallet);
851
- mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
851
+ mapMasterKeys[++nMasterKeyMaxID] = master_key ;
852
852
WalletBatch* encrypted_batch = new WalletBatch (GetDatabase ());
853
853
if (!encrypted_batch->TxnBegin ()) {
854
854
delete encrypted_batch;
855
855
encrypted_batch = nullptr ;
856
856
return false ;
857
857
}
858
- encrypted_batch->WriteMasterKey (nMasterKeyMaxID, kMasterKey );
858
+ encrypted_batch->WriteMasterKey (nMasterKeyMaxID, master_key );
859
859
860
860
for (const auto & spk_man_pair : m_spk_managers) {
861
861
auto spk_man = spk_man_pair.second .get ();
862
- if (!spk_man->Encrypt (_vMasterKey , encrypted_batch)) {
862
+ if (!spk_man->Encrypt (plain_master_key , encrypted_batch)) {
863
863
encrypted_batch->TxnAbort ();
864
864
delete encrypted_batch;
865
865
encrypted_batch = nullptr ;
0 commit comments