File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,11 @@ bool CCryptoKeyStore::EncryptSaplingKeys(CKeyingMaterial& vMasterKeyIn)
133133
134134bool CCryptoKeyStore::UnlockSaplingKeys (const CKeyingMaterial& vMasterKeyIn, bool fDecryptionThoroughlyChecked )
135135{
136+ if (mapCryptedSaplingSpendingKeys.empty ()) {
137+ LogPrintf (" %s: mapCryptedSaplingSpendingKeys empty. No need to unlock anything.\n " );
138+ return true ;
139+ }
140+
136141 bool keyFail = false ;
137142 bool keyPass = false ;
138143 CryptedSaplingSpendingKeyMap::const_iterator miSapling = mapCryptedSaplingSpendingKeys.begin ();
Original file line number Diff line number Diff line change @@ -347,17 +347,21 @@ bool CWallet::Unlock(const CKeyingMaterial& vMasterKeyIn)
347347 break ;
348348 }
349349
350- // Sapling
351- if (!UnlockSaplingKeys (vMasterKeyIn, fDecryptionThoroughlyChecked )) {
352- return false ; // only could get here if (keyFail || !keyPass).
353- }
354-
355350 if (keyPass && keyFail) {
356- LogPrintf (" The wallet is probably corrupted: Some keys decrypt but not all." );
351+ LogPrintf (" The wallet is probably corrupted: Some keys decrypt but not all.\n " );
357352 throw std::runtime_error (" Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt." );
358353 }
354+
359355 if (keyFail || !keyPass)
360356 return false ;
357+
358+ // Sapling
359+ if (!UnlockSaplingKeys (vMasterKeyIn, fDecryptionThoroughlyChecked )) {
360+ // If Sapling key encryption fail, let's unencrypt the rest of the keys
361+ LogPrintf (" Sapling wallet unlock keys failed\n " );
362+ throw std::runtime_error (" Error unlocking wallet: some Sapling keys decrypt but not all. Your wallet file may be corrupt." );
363+ }
364+
361365 vMasterKey = vMasterKeyIn;
362366 fDecryptionThoroughlyChecked = true ;
363367
@@ -748,6 +752,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
748752 Unlock (strWalletPassphrase);
749753 // if we are using HD, replace the HD seed with a new one
750754 if (m_spk_man->IsHDEnabled ()) {
755+ LogPrintf (" pre unlock setupGeneration\n " );
751756 if (!m_spk_man->SetupGeneration (false , true )) {
752757 return false ;
753758 }
You can’t perform that action at this time.
0 commit comments