Skip to content

Commit c7366d2

Browse files
author
MarcoFalke
committed
Merge #14478: Show error to user when corrupt wallet unlock fails
b4f6e58 Better error message for user when corrupt wallet unlock fails (MeshCollider) Pull request description: Mentioned here: bitcoin/bitcoin#14461 (comment) Current behavior is to assert(false) and crash, only info is printed in the log. This shows the message to the user before abort() instead. Tree-SHA512: 526f9ed9262257fca55caf7153ab913ed958b13b079d2f01db797485614d8c375815a1554276e8cf73d3838104b2691a9cf85c8d097973127ae8de9e111446bf
2 parents 2e8f9dc + b4f6e58 commit c7366d2

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)