Browse Source

Push down RPC reqWallet flag

0.13
Jonas Schnelli 10 years ago
parent
commit
b9fb692d04
  1. 5
      src/init.cpp
  2. 177
      src/rpcserver.cpp
  3. 1
      src/rpcserver.h
  4. 16
      src/wallet/rpcdump.cpp
  5. 114
      src/wallet/rpcwallet.cpp

5
src/init.cpp

@ -242,11 +242,6 @@ void OnRPCStopped()
void OnRPCPreCommand(const CRPCCommand& cmd) void OnRPCPreCommand(const CRPCCommand& cmd)
{ {
#ifdef ENABLE_WALLET
if (cmd.reqWallet && !pwalletMain)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
#endif
// Observe safe mode // Observe safe mode
string strWarning = GetWarnings("rpc"); string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) && if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&

177
src/rpcserver.cpp

@ -193,11 +193,6 @@ string CRPCTable::help(string strCommand) const
continue; continue;
if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand) if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
continue; continue;
#ifdef ENABLE_WALLET
if (pcmd->reqWallet && !pwalletMain)
continue;
#endif
try try
{ {
Array params; Array params;
@ -271,114 +266,114 @@ Value stop(const Array& params, bool fHelp)
* Call Table * Call Table
*/ */
static const CRPCCommand vRPCCommands[] = static const CRPCCommand vRPCCommands[] =
{ // category name actor (function) okSafeMode reqWallet { // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ---------- --------- // --------------------- ------------------------ ----------------------- ----------
/* Overall control/query calls */ /* Overall control/query calls */
{ "control", "getinfo", &getinfo, true, false }, /* uses wallet if enabled */ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
{ "control", "help", &help, true, false }, { "control", "help", &help, true },
{ "control", "stop", &stop, true, false }, { "control", "stop", &stop, true },
/* P2P networking */ /* P2P networking */
{ "network", "getnetworkinfo", &getnetworkinfo, true, false }, { "network", "getnetworkinfo", &getnetworkinfo, true },
{ "network", "addnode", &addnode, true, false }, { "network", "addnode", &addnode, true },
{ "network", "getaddednodeinfo", &getaddednodeinfo, true, false }, { "network", "getaddednodeinfo", &getaddednodeinfo, true },
{ "network", "getconnectioncount", &getconnectioncount, true, false }, { "network", "getconnectioncount", &getconnectioncount, true },
{ "network", "getnettotals", &getnettotals, true, false }, { "network", "getnettotals", &getnettotals, true },
{ "network", "getpeerinfo", &getpeerinfo, true, false }, { "network", "getpeerinfo", &getpeerinfo, true },
{ "network", "ping", &ping, true, false }, { "network", "ping", &ping, true },
/* Block chain and UTXO */ /* Block chain and UTXO */
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true, false }, { "blockchain", "getblockchaininfo", &getblockchaininfo, true },
{ "blockchain", "getbestblockhash", &getbestblockhash, true, false }, { "blockchain", "getbestblockhash", &getbestblockhash, true },
{ "blockchain", "getblockcount", &getblockcount, true, false }, { "blockchain", "getblockcount", &getblockcount, true },
{ "blockchain", "getblock", &getblock, true, false }, { "blockchain", "getblock", &getblock, true },
{ "blockchain", "getblockhash", &getblockhash, true, false }, { "blockchain", "getblockhash", &getblockhash, true },
{ "blockchain", "getchaintips", &getchaintips, true, false }, { "blockchain", "getchaintips", &getchaintips, true },
{ "blockchain", "getdifficulty", &getdifficulty, true, false }, { "blockchain", "getdifficulty", &getdifficulty, true },
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true, false }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true },
{ "blockchain", "getrawmempool", &getrawmempool, true, false }, { "blockchain", "getrawmempool", &getrawmempool, true },
{ "blockchain", "gettxout", &gettxout, true, false }, { "blockchain", "gettxout", &gettxout, true },
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, false }, { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
{ "blockchain", "verifychain", &verifychain, true, false }, { "blockchain", "verifychain", &verifychain, true },
/* Mining */ /* Mining */
{ "mining", "getblocktemplate", &getblocktemplate, true, false }, { "mining", "getblocktemplate", &getblocktemplate, true },
{ "mining", "getmininginfo", &getmininginfo, true, false }, { "mining", "getmininginfo", &getmininginfo, true },
{ "mining", "getnetworkhashps", &getnetworkhashps, true, false }, { "mining", "getnetworkhashps", &getnetworkhashps, true },
{ "mining", "prioritisetransaction", &prioritisetransaction, true, false }, { "mining", "prioritisetransaction", &prioritisetransaction, true },
{ "mining", "submitblock", &submitblock, true, false }, { "mining", "submitblock", &submitblock, true },
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
/* Coin generation */ /* Coin generation */
{ "generating", "getgenerate", &getgenerate, true, false }, { "generating", "getgenerate", &getgenerate, true },
{ "generating", "setgenerate", &setgenerate, true, false }, { "generating", "setgenerate", &setgenerate, true },
{ "generating", "generate", &generate, true, false }, { "generating", "generate", &generate, true },
#endif #endif
/* Raw transactions */ /* Raw transactions */
{ "rawtransactions", "createrawtransaction", &createrawtransaction, true, false }, { "rawtransactions", "createrawtransaction", &createrawtransaction, true },
{ "rawtransactions", "decoderawtransaction", &decoderawtransaction, true, false }, { "rawtransactions", "decoderawtransaction", &decoderawtransaction, true },
{ "rawtransactions", "decodescript", &decodescript, true, false }, { "rawtransactions", "decodescript", &decodescript, true },
{ "rawtransactions", "getrawtransaction", &getrawtransaction, true, false }, { "rawtransactions", "getrawtransaction", &getrawtransaction, true },
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, false, false }, { "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
{ "rawtransactions", "signrawtransaction", &signrawtransaction, false, false }, /* uses wallet if enabled */ { "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
/* Utility functions */ /* Utility functions */
{ "util", "createmultisig", &createmultisig, true, false }, { "util", "createmultisig", &createmultisig, true },
{ "util", "validateaddress", &validateaddress, true, false }, /* uses wallet if enabled */ { "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
{ "util", "verifymessage", &verifymessage, true, false }, { "util", "verifymessage", &verifymessage, true },
{ "util", "estimatefee", &estimatefee, true, false }, { "util", "estimatefee", &estimatefee, true },
{ "util", "estimatepriority", &estimatepriority, true, false }, { "util", "estimatepriority", &estimatepriority, true },
/* Not shown in help */ /* Not shown in help */
{ "hidden", "invalidateblock", &invalidateblock, true, false }, { "hidden", "invalidateblock", &invalidateblock, true },
{ "hidden", "reconsiderblock", &reconsiderblock, true, false }, { "hidden", "reconsiderblock", &reconsiderblock, true },
{ "hidden", "setmocktime", &setmocktime, true, false }, { "hidden", "setmocktime", &setmocktime, true },
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
{ "hidden", "resendwallettransactions", &resendwallettransactions, true, true }, { "hidden", "resendwallettransactions", &resendwallettransactions, true},
#endif #endif
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
/* Wallet */ /* Wallet */
{ "wallet", "addmultisigaddress", &addmultisigaddress, true, true }, { "wallet", "addmultisigaddress", &addmultisigaddress, true },
{ "wallet", "backupwallet", &backupwallet, true, true }, { "wallet", "backupwallet", &backupwallet, true },
{ "wallet", "dumpprivkey", &dumpprivkey, true, true }, { "wallet", "dumpprivkey", &dumpprivkey, true },
{ "wallet", "dumpwallet", &dumpwallet, true, true }, { "wallet", "dumpwallet", &dumpwallet, true },
{ "wallet", "encryptwallet", &encryptwallet, true, true }, { "wallet", "encryptwallet", &encryptwallet, true },
{ "wallet", "getaccountaddress", &getaccountaddress, true, true }, { "wallet", "getaccountaddress", &getaccountaddress, true },
{ "wallet", "getaccount", &getaccount, true, true }, { "wallet", "getaccount", &getaccount, true },
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, true }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
{ "wallet", "getbalance", &getbalance, false, true }, { "wallet", "getbalance", &getbalance, false },
{ "wallet", "getnewaddress", &getnewaddress, true, true }, { "wallet", "getnewaddress", &getnewaddress, true },
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true, true }, { "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
{ "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, true }, { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, true }, { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false },
{ "wallet", "gettransaction", &gettransaction, false, true }, { "wallet", "gettransaction", &gettransaction, false },
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, true }, { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false },
{ "wallet", "getwalletinfo", &getwalletinfo, false, true }, { "wallet", "getwalletinfo", &getwalletinfo, false },
{ "wallet", "importprivkey", &importprivkey, true, true }, { "wallet", "importprivkey", &importprivkey, true },
{ "wallet", "importwallet", &importwallet, true, true }, { "wallet", "importwallet", &importwallet, true },
{ "wallet", "importaddress", &importaddress, true, true }, { "wallet", "importaddress", &importaddress, true },
{ "wallet", "keypoolrefill", &keypoolrefill, true, true }, { "wallet", "keypoolrefill", &keypoolrefill, true },
{ "wallet", "listaccounts", &listaccounts, false, true }, { "wallet", "listaccounts", &listaccounts, false },
{ "wallet", "listaddressgroupings", &listaddressgroupings, false, true }, { "wallet", "listaddressgroupings", &listaddressgroupings, false },
{ "wallet", "listlockunspent", &listlockunspent, false, true }, { "wallet", "listlockunspent", &listlockunspent, false },
{ "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, true }, { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false },
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, true }, { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false },
{ "wallet", "listsinceblock", &listsinceblock, false, true }, { "wallet", "listsinceblock", &listsinceblock, false },
{ "wallet", "listtransactions", &listtransactions, false, true }, { "wallet", "listtransactions", &listtransactions, false },
{ "wallet", "listunspent", &listunspent, false, true }, { "wallet", "listunspent", &listunspent, false },
{ "wallet", "lockunspent", &lockunspent, true, true }, { "wallet", "lockunspent", &lockunspent, true },
{ "wallet", "move", &movecmd, false, true }, { "wallet", "move", &movecmd, false },
{ "wallet", "sendfrom", &sendfrom, false, true }, { "wallet", "sendfrom", &sendfrom, false },
{ "wallet", "sendmany", &sendmany, false, true }, { "wallet", "sendmany", &sendmany, false },
{ "wallet", "sendtoaddress", &sendtoaddress, false, true }, { "wallet", "sendtoaddress", &sendtoaddress, false },
{ "wallet", "setaccount", &setaccount, true, true }, { "wallet", "setaccount", &setaccount, true },
{ "wallet", "settxfee", &settxfee, true, true }, { "wallet", "settxfee", &settxfee, true },
{ "wallet", "signmessage", &signmessage, true, true }, { "wallet", "signmessage", &signmessage, true },
{ "wallet", "walletlock", &walletlock, true, true }, { "wallet", "walletlock", &walletlock, true },
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true, true }, { "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
{ "wallet", "walletpassphrase", &walletpassphrase, true, true }, { "wallet", "walletpassphrase", &walletpassphrase, true },
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
}; };

1
src/rpcserver.h

@ -98,7 +98,6 @@ public:
std::string name; std::string name;
rpcfn_type actor; rpcfn_type actor;
bool okSafeMode; bool okSafeMode;
bool reqWallet;
}; };
/** /**

16
src/wallet/rpcdump.cpp

@ -25,6 +25,7 @@ using namespace json_spirit;
using namespace std; using namespace std;
void EnsureWalletIsUnlocked(); void EnsureWalletIsUnlocked();
bool EnsureWalletIsAvailable(bool avoidException);
std::string static EncodeDumpTime(int64_t nTime) { std::string static EncodeDumpTime(int64_t nTime) {
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
@ -71,6 +72,9 @@ std::string DecodeDumpString(const std::string &str) {
Value importprivkey(const Array& params, bool fHelp) Value importprivkey(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 3) if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error( throw runtime_error(
"importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n" "importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n"
@ -142,6 +146,9 @@ Value importprivkey(const Array& params, bool fHelp)
Value importaddress(const Array& params, bool fHelp) Value importaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 3) if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error( throw runtime_error(
"importaddress \"address\" ( \"label\" rescan )\n" "importaddress \"address\" ( \"label\" rescan )\n"
@ -212,6 +219,9 @@ Value importaddress(const Array& params, bool fHelp)
Value importwallet(const Array& params, bool fHelp) Value importwallet(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"importwallet \"filename\"\n" "importwallet \"filename\"\n"
@ -313,6 +323,9 @@ Value importwallet(const Array& params, bool fHelp)
Value dumpprivkey(const Array& params, bool fHelp) Value dumpprivkey(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"dumpprivkey \"bitcoinaddress\"\n" "dumpprivkey \"bitcoinaddress\"\n"
@ -348,6 +361,9 @@ Value dumpprivkey(const Array& params, bool fHelp)
Value dumpwallet(const Array& params, bool fHelp) Value dumpwallet(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"dumpwallet \"filename\"\n" "dumpwallet \"filename\"\n"

114
src/wallet/rpcwallet.cpp

@ -37,6 +37,18 @@ std::string HelpRequiringPassphrase()
: ""; : "";
} }
bool EnsureWalletIsAvailable(bool avoidException)
{
if (!pwalletMain)
{
if (!avoidException)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
else
return false;
}
return true;
}
void EnsureWalletIsUnlocked() void EnsureWalletIsUnlocked()
{ {
if (pwalletMain->IsLocked()) if (pwalletMain->IsLocked())
@ -77,6 +89,9 @@ string AccountFromValue(const Value& value)
Value getnewaddress(const Array& params, bool fHelp) Value getnewaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error( throw runtime_error(
"getnewaddress ( \"account\" )\n" "getnewaddress ( \"account\" )\n"
@ -153,6 +168,9 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
Value getaccountaddress(const Array& params, bool fHelp) Value getaccountaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"getaccountaddress \"account\"\n" "getaccountaddress \"account\"\n"
@ -182,6 +200,9 @@ Value getaccountaddress(const Array& params, bool fHelp)
Value getrawchangeaddress(const Array& params, bool fHelp) Value getrawchangeaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error( throw runtime_error(
"getrawchangeaddress\n" "getrawchangeaddress\n"
@ -214,6 +235,9 @@ Value getrawchangeaddress(const Array& params, bool fHelp)
Value setaccount(const Array& params, bool fHelp) Value setaccount(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 2) if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error( throw runtime_error(
"setaccount \"bitcoinaddress\" \"account\"\n" "setaccount \"bitcoinaddress\" \"account\"\n"
@ -257,6 +281,9 @@ Value setaccount(const Array& params, bool fHelp)
Value getaccount(const Array& params, bool fHelp) Value getaccount(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"getaccount \"bitcoinaddress\"\n" "getaccount \"bitcoinaddress\"\n"
@ -286,6 +313,9 @@ Value getaccount(const Array& params, bool fHelp)
Value getaddressesbyaccount(const Array& params, bool fHelp) Value getaddressesbyaccount(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"getaddressesbyaccount \"account\"\n" "getaddressesbyaccount \"account\"\n"
@ -351,6 +381,9 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
Value sendtoaddress(const Array& params, bool fHelp) Value sendtoaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 2 || params.size() > 5) if (fHelp || params.size() < 2 || params.size() > 5)
throw runtime_error( throw runtime_error(
"sendtoaddress \"bitcoinaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" "sendtoaddress \"bitcoinaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n"
@ -404,6 +437,9 @@ Value sendtoaddress(const Array& params, bool fHelp)
Value listaddressgroupings(const Array& params, bool fHelp) Value listaddressgroupings(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp) if (fHelp)
throw runtime_error( throw runtime_error(
"listaddressgroupings\n" "listaddressgroupings\n"
@ -453,6 +489,9 @@ Value listaddressgroupings(const Array& params, bool fHelp)
Value signmessage(const Array& params, bool fHelp) Value signmessage(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 2) if (fHelp || params.size() != 2)
throw runtime_error( throw runtime_error(
"signmessage \"bitcoinaddress\" \"message\"\n" "signmessage \"bitcoinaddress\" \"message\"\n"
@ -506,6 +545,9 @@ Value signmessage(const Array& params, bool fHelp)
Value getreceivedbyaddress(const Array& params, bool fHelp) Value getreceivedbyaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 2) if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error( throw runtime_error(
"getreceivedbyaddress \"bitcoinaddress\" ( minconf )\n" "getreceivedbyaddress \"bitcoinaddress\" ( minconf )\n"
@ -561,6 +603,9 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
Value getreceivedbyaccount(const Array& params, bool fHelp) Value getreceivedbyaccount(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 2) if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error( throw runtime_error(
"getreceivedbyaccount \"account\" ( minconf )\n" "getreceivedbyaccount \"account\" ( minconf )\n"
@ -647,6 +692,9 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
Value getbalance(const Array& params, bool fHelp) Value getbalance(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 3) if (fHelp || params.size() > 3)
throw runtime_error( throw runtime_error(
"getbalance ( \"account\" minconf includeWatchonly )\n" "getbalance ( \"account\" minconf includeWatchonly )\n"
@ -719,6 +767,9 @@ Value getbalance(const Array& params, bool fHelp)
Value getunconfirmedbalance(const Array &params, bool fHelp) Value getunconfirmedbalance(const Array &params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 0) if (fHelp || params.size() > 0)
throw runtime_error( throw runtime_error(
"getunconfirmedbalance\n" "getunconfirmedbalance\n"
@ -732,6 +783,9 @@ Value getunconfirmedbalance(const Array &params, bool fHelp)
Value movecmd(const Array& params, bool fHelp) Value movecmd(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 3 || params.size() > 5) if (fHelp || params.size() < 3 || params.size() > 5)
throw runtime_error( throw runtime_error(
"move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n" "move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n"
@ -799,6 +853,9 @@ Value movecmd(const Array& params, bool fHelp)
Value sendfrom(const Array& params, bool fHelp) Value sendfrom(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 3 || params.size() > 6) if (fHelp || params.size() < 3 || params.size() > 6)
throw runtime_error( throw runtime_error(
"sendfrom \"fromaccount\" \"tobitcoinaddress\" amount ( minconf \"comment\" \"comment-to\" )\n" "sendfrom \"fromaccount\" \"tobitcoinaddress\" amount ( minconf \"comment\" \"comment-to\" )\n"
@ -859,6 +916,9 @@ Value sendfrom(const Array& params, bool fHelp)
Value sendmany(const Array& params, bool fHelp) Value sendmany(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 2 || params.size() > 5) if (fHelp || params.size() < 2 || params.size() > 5)
throw runtime_error( throw runtime_error(
"sendmany \"fromaccount\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] )\n" "sendmany \"fromaccount\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] )\n"
@ -965,6 +1025,9 @@ extern CScript _createmultisig_redeemScript(const Array& params);
Value addmultisigaddress(const Array& params, bool fHelp) Value addmultisigaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 2 || params.size() > 3) if (fHelp || params.size() < 2 || params.size() > 3)
{ {
string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n" string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n"
@ -1143,6 +1206,9 @@ Value ListReceived(const Array& params, bool fByAccounts)
Value listreceivedbyaddress(const Array& params, bool fHelp) Value listreceivedbyaddress(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 3) if (fHelp || params.size() > 3)
throw runtime_error( throw runtime_error(
"listreceivedbyaddress ( minconf includeempty includeWatchonly)\n" "listreceivedbyaddress ( minconf includeempty includeWatchonly)\n"
@ -1177,6 +1243,9 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
Value listreceivedbyaccount(const Array& params, bool fHelp) Value listreceivedbyaccount(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 3) if (fHelp || params.size() > 3)
throw runtime_error( throw runtime_error(
"listreceivedbyaccount ( minconf includeempty includeWatchonly)\n" "listreceivedbyaccount ( minconf includeempty includeWatchonly)\n"
@ -1304,6 +1373,9 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
Value listtransactions(const Array& params, bool fHelp) Value listtransactions(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 4) if (fHelp || params.size() > 4)
throw runtime_error( throw runtime_error(
"listtransactions ( \"account\" count from includeWatchonly)\n" "listtransactions ( \"account\" count from includeWatchonly)\n"
@ -1415,6 +1487,9 @@ Value listtransactions(const Array& params, bool fHelp)
Value listaccounts(const Array& params, bool fHelp) Value listaccounts(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 2) if (fHelp || params.size() > 2)
throw runtime_error( throw runtime_error(
"listaccounts ( minconf includeWatchonly)\n" "listaccounts ( minconf includeWatchonly)\n"
@ -1492,6 +1567,9 @@ Value listaccounts(const Array& params, bool fHelp)
Value listsinceblock(const Array& params, bool fHelp) Value listsinceblock(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp) if (fHelp)
throw runtime_error( throw runtime_error(
"listsinceblock ( \"blockhash\" target-confirmations includeWatchonly)\n" "listsinceblock ( \"blockhash\" target-confirmations includeWatchonly)\n"
@ -1580,6 +1658,9 @@ Value listsinceblock(const Array& params, bool fHelp)
Value gettransaction(const Array& params, bool fHelp) Value gettransaction(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 2) if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error( throw runtime_error(
"gettransaction \"txid\" ( includeWatchonly )\n" "gettransaction \"txid\" ( includeWatchonly )\n"
@ -1655,6 +1736,9 @@ Value gettransaction(const Array& params, bool fHelp)
Value backupwallet(const Array& params, bool fHelp) Value backupwallet(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 1) if (fHelp || params.size() != 1)
throw runtime_error( throw runtime_error(
"backupwallet \"destination\"\n" "backupwallet \"destination\"\n"
@ -1678,6 +1762,9 @@ Value backupwallet(const Array& params, bool fHelp)
Value keypoolrefill(const Array& params, bool fHelp) Value keypoolrefill(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error( throw runtime_error(
"keypoolrefill ( newsize )\n" "keypoolrefill ( newsize )\n"
@ -1719,6 +1806,9 @@ static void LockWallet(CWallet* pWallet)
Value walletpassphrase(const Array& params, bool fHelp) Value walletpassphrase(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error( throw runtime_error(
"walletpassphrase \"passphrase\" timeout\n" "walletpassphrase \"passphrase\" timeout\n"
@ -1776,6 +1866,9 @@ Value walletpassphrase(const Array& params, bool fHelp)
Value walletpassphrasechange(const Array& params, bool fHelp) Value walletpassphrasechange(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error( throw runtime_error(
"walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n" "walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n"
@ -1819,6 +1912,9 @@ Value walletpassphrasechange(const Array& params, bool fHelp)
Value walletlock(const Array& params, bool fHelp) Value walletlock(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0))
throw runtime_error( throw runtime_error(
"walletlock\n" "walletlock\n"
@ -1855,6 +1951,9 @@ Value walletlock(const Array& params, bool fHelp)
Value encryptwallet(const Array& params, bool fHelp) Value encryptwallet(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1)) if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
throw runtime_error( throw runtime_error(
"encryptwallet \"passphrase\"\n" "encryptwallet \"passphrase\"\n"
@ -1909,6 +2008,9 @@ Value encryptwallet(const Array& params, bool fHelp)
Value lockunspent(const Array& params, bool fHelp) Value lockunspent(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 2) if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error( throw runtime_error(
"lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n" "lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n"
@ -1990,6 +2092,9 @@ Value lockunspent(const Array& params, bool fHelp)
Value listlockunspent(const Array& params, bool fHelp) Value listlockunspent(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() > 0) if (fHelp || params.size() > 0)
throw runtime_error( throw runtime_error(
"listlockunspent\n" "listlockunspent\n"
@ -2036,6 +2141,9 @@ Value listlockunspent(const Array& params, bool fHelp)
Value settxfee(const Array& params, bool fHelp) Value settxfee(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() < 1 || params.size() > 1) if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error( throw runtime_error(
"settxfee amount\n" "settxfee amount\n"
@ -2062,6 +2170,9 @@ Value settxfee(const Array& params, bool fHelp)
Value getwalletinfo(const Array& params, bool fHelp) Value getwalletinfo(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 0) if (fHelp || params.size() != 0)
throw runtime_error( throw runtime_error(
"getwalletinfo\n" "getwalletinfo\n"
@ -2099,6 +2210,9 @@ Value getwalletinfo(const Array& params, bool fHelp)
Value resendwallettransactions(const Array& params, bool fHelp) Value resendwallettransactions(const Array& params, bool fHelp)
{ {
if (!EnsureWalletIsAvailable(fHelp))
return Value::null;
if (fHelp || params.size() != 0) if (fHelp || params.size() != 0)
throw runtime_error( throw runtime_error(
"resendwallettransactions\n" "resendwallettransactions\n"

Loading…
Cancel
Save