diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index c07aff367..df21d31fa 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -150,6 +150,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 2) ConvertTo(params[2]); if (strMethod == "listaccounts" && n > 0) ConvertTo(params[0]); if (strMethod == "walletpassphrase" && n > 1) ConvertTo(params[1]); + if (strMethod == "walletpassphrase" && n > 2) ConvertTo(params[2]); if (strMethod == "getblocktemplate" && n > 0) ConvertTo(params[0]); if (strMethod == "listsinceblock" && n > 1) ConvertTo(params[1]); if (strMethod == "sendmany" && n > 1) ConvertTo(params[1]); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 7879f94d7..e1c4c245d 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1563,23 +1563,25 @@ Value walletpassphrase(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3)) throw runtime_error( - "walletpassphrase \"passphrase\" \n" + "walletpassphrase \"passphrase\" timeout ( anonymizeonly )>\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 darkcoins\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. anonymizeonly (boolean, optional, default=flase) If is true sending functions are disabled." "\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" "\nExamples:\n" - "\nunlock the wallet for 60 seconds\n" + "\nUlock the wallet for 60 seconds\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") + + "\nUlock the wallet for 60 seconds but allow Darksend mixing only\n" + + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60 true") + "\nLock the wallet again (before 60 seconds)\n" + HelpExampleCli("walletlock", "") + "\nAs json rpc call\n" - + HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60") + - "if [anonymizeonly] is true sending functions are disabled." + + HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60") ); if (fHelp) @@ -1594,24 +1596,15 @@ Value walletpassphrase(const Array& params, bool fHelp) // Alternately, find a way to make params[0] mlock()'d to begin with. strWalletPass = params[0].get_str().c_str(); - if (strWalletPass.length() > 0) - { - bool anonymizeOnly; - if (params.size() == 3) - anonymizeOnly = params[2].get_bool(); - else - anonymizeOnly = false; + bool anonymizeOnly = false; + if (params.size() == 3) + anonymizeOnly = params[2].get_bool(); - if (!pwalletMain->IsLocked() && pwalletMain->fWalletUnlockAnonymizeOnly && anonymizeOnly) - throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already unlocked."); + if (!pwalletMain->IsLocked() && pwalletMain->fWalletUnlockAnonymizeOnly && anonymizeOnly) + throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already unlocked."); - if (!pwalletMain->Unlock(strWalletPass, anonymizeOnly)) - throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); - } - else - throw runtime_error( - "walletpassphrase \n" - "Stores the wallet decryption key in memory for seconds."); + if (!pwalletMain->Unlock(strWalletPass, anonymizeOnly)) + throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); pwalletMain->TopUpKeyPool();