@@ -620,16 +620,16 @@ static bool DecryptMasterKey(const SecureString& wallet_passphrase, const CMaste
620
620
621
621
bool CWallet::Unlock (const SecureString& strWalletPassphrase)
622
622
{
623
- CKeyingMaterial _vMasterKey ;
623
+ CKeyingMaterial plain_master_key ;
624
624
625
625
{
626
626
LOCK (cs_wallet);
627
- for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
627
+ for (const auto & [_, master_key] : mapMasterKeys)
628
628
{
629
- if (!DecryptMasterKey (strWalletPassphrase, pMasterKey. second , _vMasterKey )) {
629
+ if (!DecryptMasterKey (strWalletPassphrase, master_key, plain_master_key )) {
630
630
continue ; // try another master key
631
631
}
632
- if (Unlock (_vMasterKey )) {
632
+ if (Unlock (plain_master_key )) {
633
633
// Now that we've unlocked, upgrade the key metadata
634
634
UpgradeKeyMetadata ();
635
635
// Now that we've unlocked, upgrade the descriptor cache
@@ -649,20 +649,20 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
649
649
LOCK2 (m_relock_mutex, cs_wallet);
650
650
Lock ();
651
651
652
- CKeyingMaterial _vMasterKey ;
653
- for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
652
+ CKeyingMaterial plain_master_key ;
653
+ for (auto & [master_key_id, master_key] : mapMasterKeys)
654
654
{
655
- if (!DecryptMasterKey (strOldWalletPassphrase, pMasterKey. second , _vMasterKey )) {
655
+ if (!DecryptMasterKey (strOldWalletPassphrase, master_key, plain_master_key )) {
656
656
return false ;
657
657
}
658
- if (Unlock (_vMasterKey ))
658
+ if (Unlock (plain_master_key ))
659
659
{
660
- if (!EncryptMasterKey (strNewWalletPassphrase, _vMasterKey, pMasterKey. second )) {
660
+ if (!EncryptMasterKey (strNewWalletPassphrase, plain_master_key, master_key )) {
661
661
return false ;
662
662
}
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 );
664
664
665
- WalletBatch (GetDatabase ()).WriteMasterKey (pMasterKey. first , pMasterKey. second );
665
+ WalletBatch (GetDatabase ()).WriteMasterKey (master_key_id, master_key );
666
666
if (fWasLocked )
667
667
Lock ();
668
668
return true ;
@@ -837,35 +837,35 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
837
837
if (IsCrypted ())
838
838
return false ;
839
839
840
- CKeyingMaterial _vMasterKey ;
840
+ CKeyingMaterial plain_master_key ;
841
841
842
- _vMasterKey .resize (WALLET_CRYPTO_KEY_SIZE);
843
- GetStrongRandBytes (_vMasterKey );
842
+ plain_master_key .resize (WALLET_CRYPTO_KEY_SIZE);
843
+ GetStrongRandBytes (plain_master_key );
844
844
845
- CMasterKey kMasterKey ;
845
+ CMasterKey master_key ;
846
846
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 );
849
849
850
- if (!EncryptMasterKey (strWalletPassphrase, _vMasterKey, kMasterKey )) {
850
+ if (!EncryptMasterKey (strWalletPassphrase, plain_master_key, master_key )) {
851
851
return false ;
852
852
}
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 );
854
854
855
855
{
856
856
LOCK2 (m_relock_mutex, cs_wallet);
857
- mapMasterKeys[++nMasterKeyMaxID] = kMasterKey ;
857
+ mapMasterKeys[++nMasterKeyMaxID] = master_key ;
858
858
WalletBatch* encrypted_batch = new WalletBatch (GetDatabase ());
859
859
if (!encrypted_batch->TxnBegin ()) {
860
860
delete encrypted_batch;
861
861
encrypted_batch = nullptr ;
862
862
return false ;
863
863
}
864
- encrypted_batch->WriteMasterKey (nMasterKeyMaxID, kMasterKey );
864
+ encrypted_batch->WriteMasterKey (nMasterKeyMaxID, master_key );
865
865
866
866
for (const auto & spk_man_pair : m_spk_managers) {
867
867
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)) {
869
869
encrypted_batch->TxnAbort ();
870
870
delete encrypted_batch;
871
871
encrypted_batch = nullptr ;
0 commit comments