Allow the default key to be unavailable

This solves the issue where no default key can be added after -salvagewallet.
This commit is contained in:
Pieter Wuille
2013-04-25 19:30:28 +02:00
committed by Pieter Wuille
parent 77a1e12eed
commit 360cfe142c
4 changed files with 32 additions and 24 deletions

View File

@ -939,11 +939,11 @@ bool AppInit2(boost::thread_group& threadGroup)
RandAddSeedPerfmon();
CPubKey newDefaultKey;
if (!pwalletMain->GetKeyFromPool(newDefaultKey, false))
strErrors << _("Cannot initialize keypool") << "\n";
pwalletMain->SetDefaultKey(newDefaultKey);
if (!pwalletMain->SetAddressBookName(pwalletMain->vchDefaultKey.GetID(), ""))
strErrors << _("Cannot write default address") << "\n";
if (pwalletMain->GetKeyFromPool(newDefaultKey, false)) {
pwalletMain->SetDefaultKey(newDefaultKey);
if (!pwalletMain->SetAddressBookName(pwalletMain->vchDefaultKey.GetID(), ""))
strErrors << _("Cannot write default address") << "\n";
}
}
printf("%s", strErrors.str().c_str());