@@ -620,16 +620,16 @@ static bool DecryptMasterKey(const SecureString& wallet_passphrase, const CMaste
620620
621621bool CWallet::Unlock (const SecureString& strWalletPassphrase)
622622{
623- CKeyingMaterial _vMasterKey ;
623+ CKeyingMaterial plain_master_key ;
624624
625625 {
626626 LOCK (cs_wallet);
627- for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
627+ for (const auto & [_, master_key] : mapMasterKeys)
628628 {
629- if (!DecryptMasterKey (strWalletPassphrase, pMasterKey. second , _vMasterKey )) {
629+ if (!DecryptMasterKey (strWalletPassphrase, master_key, plain_master_key )) {
630630 continue ; // try another master key
631631 }
632- if (Unlock (_vMasterKey )) {
632+ if (Unlock (plain_master_key )) {
633633 // Now that we've unlocked, upgrade the key metadata
634634 UpgradeKeyMetadata ();
635635 // Now that we've unlocked, upgrade the descriptor cache
@@ -649,20 +649,20 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
649649 LOCK2 (m_relock_mutex, cs_wallet);
650650 Lock ();
651651
652- CKeyingMaterial _vMasterKey ;
653- for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
652+ CKeyingMaterial plain_master_key ;
653+ for (auto & [master_key_id, master_key] : mapMasterKeys)
654654 {
655- if (!DecryptMasterKey (strOldWalletPassphrase, pMasterKey. second , _vMasterKey )) {
655+ if (!DecryptMasterKey (strOldWalletPassphrase, master_key, plain_master_key )) {
656656 return false ;
657657 }
658- if (Unlock (_vMasterKey ))
658+ if (Unlock (plain_master_key ))
659659 {
660- if (!EncryptMasterKey (strNewWalletPassphrase, _vMasterKey, pMasterKey. second )) {
660+ if (!EncryptMasterKey (strNewWalletPassphrase, plain_master_key, master_key )) {
661661 return false ;
662662 }
663- WalletLogPrintf (" Wallet passphrase changed to an nDeriveIterations of %i\n " , pMasterKey. second .nDeriveIterations );
663+ WalletLogPrintf (" Wallet passphrase changed to an nDeriveIterations of %i\n " , master_key .nDeriveIterations );
664664
665- WalletBatch (GetDatabase ()).WriteMasterKey (pMasterKey. first , pMasterKey. second );
665+ WalletBatch (GetDatabase ()).WriteMasterKey (master_key_id, master_key );
666666 if (fWasLocked )
667667 Lock ();
668668 return true ;
@@ -837,35 +837,35 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
837837 if (IsCrypted ())
838838 return false ;
839839
840- CKeyingMaterial _vMasterKey ;
840+ CKeyingMaterial plain_master_key ;
841841
842- _vMasterKey .resize (WALLET_CRYPTO_KEY_SIZE);
843- GetStrongRandBytes (_vMasterKey );
842+ plain_master_key .resize (WALLET_CRYPTO_KEY_SIZE);
843+ GetStrongRandBytes (plain_master_key );
844844
845- CMasterKey kMasterKey ;
845+ CMasterKey master_key ;
846846
847- kMasterKey .vchSalt .resize (WALLET_CRYPTO_SALT_SIZE);
848- GetStrongRandBytes (kMasterKey .vchSalt );
847+ master_key .vchSalt .resize (WALLET_CRYPTO_SALT_SIZE);
848+ GetStrongRandBytes (master_key .vchSalt );
849849
850- if (!EncryptMasterKey (strWalletPassphrase, _vMasterKey, kMasterKey )) {
850+ if (!EncryptMasterKey (strWalletPassphrase, plain_master_key, master_key )) {
851851 return false ;
852852 }
853- WalletLogPrintf (" Encrypting Wallet with an nDeriveIterations of %i\n " , kMasterKey .nDeriveIterations );
853+ WalletLogPrintf (" Encrypting Wallet with an nDeriveIterations of %i\n " , master_key .nDeriveIterations );
854854
855855 {
856856 LOCK2 (m_relock_mutex, cs_wallet);
857- mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
857+ mapMasterKeys[++nMasterKeyMaxID] = master_key ;
858858 WalletBatch* encrypted_batch = new WalletBatch (GetDatabase ());
859859 if (!encrypted_batch->TxnBegin ()) {
860860 delete encrypted_batch;
861861 encrypted_batch = nullptr ;
862862 return false ;
863863 }
864- encrypted_batch->WriteMasterKey (nMasterKeyMaxID, kMasterKey );
864+ encrypted_batch->WriteMasterKey (nMasterKeyMaxID, master_key );
865865
866866 for (const auto & spk_man_pair : m_spk_managers) {
867867 auto spk_man = spk_man_pair.second .get ();
868- if (!spk_man->Encrypt (_vMasterKey , encrypted_batch)) {
868+ if (!spk_man->Encrypt (plain_master_key , encrypted_batch)) {
869869 encrypted_batch->TxnAbort ();
870870 delete encrypted_batch;
871871 encrypted_batch = nullptr ;
0 commit comments