Add -minetolocalwallet flag, enforced on -mineraddress
This commit is contained in:
parent
c1de826f10
commit
f49bcdf92b
32
src/init.cpp
32
src/init.cpp
|
@ -428,6 +428,14 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 1));
|
||||
strUsage += HelpMessageOpt("-equihashsolver=<name>", _("Specify the Equihash solver to be used if enabled (default: \"default\")"));
|
||||
strUsage += HelpMessageOpt("-mineraddress=<addr>", _("Send mined coins to a specific single address"));
|
||||
strUsage += HelpMessageOpt("-minetolocalwallet", strprintf(
|
||||
_("Require that mined blocks use a coinbase address in the local wallet (default: %u)"),
|
||||
#ifdef ENABLE_WALLET
|
||||
1
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
));
|
||||
#endif
|
||||
|
||||
strUsage += HelpMessageGroup(_("RPC server options:"));
|
||||
|
@ -1459,6 +1467,30 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
LogPrintf("No wallet support compiled in!\n");
|
||||
#endif // !ENABLE_WALLET
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
if (mapArgs.count("-mineraddress")) {
|
||||
#ifdef ENABLE_WALLET
|
||||
auto mineToLocalWallet = GetBoolArg("-minetolocalwallet", true);
|
||||
bool minerAddressInLocalWallet = false;
|
||||
if (pwalletMain) {
|
||||
// Address has alreday been validated
|
||||
CBitcoinAddress addr(mapArgs["-mineraddress"]);
|
||||
CKeyID keyID;
|
||||
addr.GetKeyID(keyID);
|
||||
minerAddressInLocalWallet = pwalletMain->HaveKey(keyID);
|
||||
}
|
||||
if (mineToLocalWallet && !minerAddressInLocalWallet) {
|
||||
return InitError(_("-mineraddress is not in the local wallet. Either use a local address, or set -minetolocalwallet=0"));
|
||||
}
|
||||
#else // ENABLE_WALLET
|
||||
auto mineToLocalWallet = 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."));
|
||||
}
|
||||
#endif // !ENABLE_WALLET
|
||||
}
|
||||
#endif // ENABLE_MINING
|
||||
|
||||
// ********************************************************* Step 9: data directory maintenance
|
||||
|
||||
// if pruning, unset the service bit and perform the initial blockstore prune
|
||||
|
|
Loading…
Reference in New Issue