if (pwalletMain->IsLocked())
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
+ if (fWalletUnlockStakeOnly)
+ throw JSONRPCError(-13, "Error: Wallet unlocked for coinstake only.");
// Check funds
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
Value walletpassphrase(const Array& params, bool fHelp)
{
- if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
+ if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3))
throw runtime_error(
- "walletpassphrase <passphrase> <timeout>\n"
- "Stores the wallet decryption key in memory for <timeout> seconds.");
+ "walletpassphrase <passphrase> <timeout> [stakeonly]\n"
+ "Stores the wallet decryption key in memory for <timeout> seconds."
+ "stakeonly is an optional true/false allowing only stake creation.");
if (fHelp)
return true;
if (!pwalletMain->IsCrypted())
throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
if (!pwalletMain->IsLocked())
- throw JSONRPCError(-17, "Error: Wallet is already unlocked.");
+ throw JSONRPCError(-17, "Error: Wallet is already unlocked, use walletlock first if need to change unlock settings.");
// Note that the walletpassphrase is stored in params[0] which is not mlock()ed
SecureString strWalletPass;
int* pnSleepTime = new int(params[1].get_int());
CreateThread(ThreadCleanWalletPassphrase, pnSleepTime);
+ // ppcoin: if user OS account compromised prevent trivial sendmoney commands
+ if (params.size() > 2)
+ fWalletUnlockStakeOnly = params[2].get_bool();
+ else
+ fWalletUnlockStakeOnly = false;
+
return Value::null;
}
if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "walletpassphrase" && n > 1) ConvertTo<boost::int64_t>(params[1]);
+ if (strMethod == "walletpassphrase" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "listsinceblock" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendmany" && n > 1)
{
return false;
}
+// ppcoin: optional setting to create coinstake only when unlocked;
+// serves to disable the trivial sendmoney when OS account compromised
+bool fWalletUnlockStakeOnly = false;
+
bool CWallet::Unlock(const SecureString& strWalletPassphrase)
{
if (!IsLocked())
printf("SendMoney() : %s", strError.c_str());
return strError;
}
+ if (fWalletUnlockStakeOnly)
+ {
+ string strError = _("Error: Wallet unlocked for coinstake only, unable to create transaction.");
+ printf("SendMoney() : %s", strError.c_str());
+ return strError;
+ }
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
{
string strError;