Skip to content

Commit b4f6e58

Browse files
committed
Better error message for user when corrupt wallet unlock fails
1 parent be99270 commit b4f6e58

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/qt/askpassphrasedialog.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,15 @@ void AskPassphraseDialog::accept()
152152
}
153153
} break;
154154
case Unlock:
155-
if(!model->setWalletLocked(false, oldpass))
156-
{
157-
QMessageBox::critical(this, tr("Wallet unlock failed"),
158-
tr("The passphrase entered for the wallet decryption was incorrect."));
159-
}
160-
else
161-
{
162-
QDialog::accept(); // Success
155+
try {
156+
if (!model->setWalletLocked(false, oldpass)) {
157+
QMessageBox::critical(this, tr("Wallet unlock failed"),
158+
tr("The passphrase entered for the wallet decryption was incorrect."));
159+
} else {
160+
QDialog::accept(); // Success
161+
}
162+
} catch (const std::runtime_error& e) {
163+
QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
163164
}
164165
break;
165166
case Decrypt:

src/wallet/crypter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
202202
if (keyPass && keyFail)
203203
{
204204
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
205-
assert(false);
205+
throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt.");
206206
}
207207
if (keyFail || !keyPass)
208208
return false;

0 commit comments

Comments
 (0)