Merge #14478: Show error to user when corrupt wallet unlock fails

b4f6e58ca5 Better error message for user when corrupt wallet unlock fails (MeshCollider)

Pull request description:

  Mentioned here: https://github.com/bitcoin/bitcoin/issues/14461#issuecomment-429183503

  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
This commit is contained in:
MarcoFalke 2018-11-14 11:26:51 -05:00
commit c7366d2399
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25
2 changed files with 10 additions and 9 deletions

View file

@ -152,15 +152,16 @@ void AskPassphraseDialog::accept()
} }
} break; } break;
case Unlock: case Unlock:
if(!model->setWalletLocked(false, oldpass)) try {
{ if (!model->setWalletLocked(false, oldpass)) {
QMessageBox::critical(this, tr("Wallet unlock failed"), QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect.")); tr("The passphrase entered for the wallet decryption was incorrect."));
} } else {
else
{
QDialog::accept(); // Success QDialog::accept(); // Success
} }
} catch (const std::runtime_error& e) {
QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
}
break; break;
case Decrypt: case Decrypt:
if(!model->setWalletEncrypted(false, oldpass)) if(!model->setWalletEncrypted(false, oldpass))

View file

@ -202,7 +202,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
if (keyPass && keyFail) if (keyPass && keyFail)
{ {
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n"); LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
assert(false); throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt.");
} }
if (keyFail || !keyPass) if (keyFail || !keyPass)
return false; return false;