Skip to content

Commit

Permalink
StakeOnly Commandline Support
Browse files Browse the repository at this point in the history
Re-Added the Commandline Support for StakeOnly via walletpassphrase.
  • Loading branch information
Oliver Ziegler authored and Oliver Ziegler committed Feb 6, 2019
1 parent 0fccc50 commit 76d7b02
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void EnsureWalletIsUnlocked()
{
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");

if (fWalletUnlockStakingOnly)
throw(JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Wallet unlocked for staking only."));
}

void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
Expand Down Expand Up @@ -1929,12 +1932,13 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp)

if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error(
"walletpassphrase \"passphrase\" timeout\n"
"walletpassphrase \"passphrase\" timeout [mintonly]\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
"This is needed prior to performing transactions related to private keys such as sending trezarcoin\n"
"\nArguments:\n"
"1. \"passphrase\" (string, required) The wallet passphrase\n"
"2. timeout (numeric, required) The time to keep the decryption key in seconds.\n"
"3. mintonly (boolean, optional - true or false) Does only unlock for Staking if true.\n"
"\nNote:\n"
"Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n"
"time that overrides the old one.\n"
Expand Down Expand Up @@ -1978,6 +1982,15 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp)
nWalletUnlockTime = GetTime() + nSleepTime;
RPCRunLater("lockwallet", boost::bind(LockWallet, pwalletMain), nSleepTime);

/* Disables some wallet functionality if unlocked for staking only */
if (params.size() > 2)
{
if ((params[2].get_str() == "true") || (params[2].get_str() == "True"))
fWalletUnlockStakingOnly = true;
}
else
fWalletUnlockStakingOnly = false;

return NullUniValue;
}

Expand Down

0 comments on commit 76d7b02

Please sign in to comment.