Address @str4d's comment about the case where -gen is not set.

Also avoid shadowing mineToLocalWallet variable.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2017-02-09 23:59:56 +00:00
parent d32511c72c
commit 3df7c4c8c0
1 changed files with 3 additions and 5 deletions

View File

@ -1508,18 +1508,16 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
#ifdef ENABLE_MINING #ifdef ENABLE_MINING
#ifndef ENABLE_WALLET #ifndef ENABLE_WALLET
auto mineToLocalWallet = GetBoolArg("-minetolocalwallet", false); if (GetBoolArg("-minetolocalwallet", false)) {
if (mineToLocalWallet) {
return InitError(_("Zcash was not built with wallet support. Set -minetolocalwallet=0 to use -mineraddress, or rebuild Zcash with wallet support.")); return InitError(_("Zcash was not built with wallet support. Set -minetolocalwallet=0 to use -mineraddress, or rebuild Zcash with wallet support."));
} }
if (!mapArgs.count("-mineraddress")) { if (GetArg("-mineraddress", "").empty() && GetBoolArg("-gen", false)) {
return InitError(_("Zcash was not built with wallet support. Set -mineraddress, or rebuild Zcash with wallet support.")); return InitError(_("Zcash was not built with wallet support. Set -mineraddress, or rebuild Zcash with wallet support."));
} }
#endif // !ENABLE_WALLET #endif // !ENABLE_WALLET
if (mapArgs.count("-mineraddress")) { if (mapArgs.count("-mineraddress")) {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
auto mineToLocalWallet = GetBoolArg("-minetolocalwallet", true);
bool minerAddressInLocalWallet = false; bool minerAddressInLocalWallet = false;
if (pwalletMain) { if (pwalletMain) {
// Address has alreday been validated // Address has alreday been validated
@ -1528,7 +1526,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
addr.GetKeyID(keyID); addr.GetKeyID(keyID);
minerAddressInLocalWallet = pwalletMain->HaveKey(keyID); minerAddressInLocalWallet = pwalletMain->HaveKey(keyID);
} }
if (mineToLocalWallet && !minerAddressInLocalWallet) { if (GetBoolArg("-minetolocalwallet", true) && !minerAddressInLocalWallet) {
return InitError(_("-mineraddress is not in the local wallet. Either use a local address, or set -minetolocalwallet=0")); return InitError(_("-mineraddress is not in the local wallet. Either use a local address, or set -minetolocalwallet=0"));
} }
#endif // ENABLE_WALLET #endif // ENABLE_WALLET