[RPC, Wallet] Move RPC dispatch table registration to wallet/ code
Allow extending the rpc dispatch table by appending commands when server is not running.
This commit is contained in:
@@ -309,9 +309,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "rawtransactions", "getrawtransaction", &getrawtransaction, true },
|
||||
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
|
||||
{ "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
|
||||
#ifdef ENABLE_WALLET
|
||||
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, false },
|
||||
#endif
|
||||
|
||||
/* Utility functions */
|
||||
{ "util", "createmultisig", &createmultisig, true },
|
||||
@@ -326,54 +323,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "hidden", "invalidateblock", &invalidateblock, true },
|
||||
{ "hidden", "reconsiderblock", &reconsiderblock, true },
|
||||
{ "hidden", "setmocktime", &setmocktime, true },
|
||||
#ifdef ENABLE_WALLET
|
||||
{ "hidden", "resendwallettransactions", &resendwallettransactions, true},
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
/* Wallet */
|
||||
{ "wallet", "addmultisigaddress", &addmultisigaddress, true },
|
||||
{ "wallet", "backupwallet", &backupwallet, true },
|
||||
{ "wallet", "dumpprivkey", &dumpprivkey, true },
|
||||
{ "wallet", "dumpwallet", &dumpwallet, true },
|
||||
{ "wallet", "encryptwallet", &encryptwallet, true },
|
||||
{ "wallet", "getaccountaddress", &getaccountaddress, true },
|
||||
{ "wallet", "getaccount", &getaccount, true },
|
||||
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
|
||||
{ "wallet", "getbalance", &getbalance, false },
|
||||
{ "wallet", "getnewaddress", &getnewaddress, true },
|
||||
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
|
||||
{ "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
|
||||
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false },
|
||||
{ "wallet", "gettransaction", &gettransaction, false },
|
||||
{ "wallet", "abandontransaction", &abandontransaction, false },
|
||||
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false },
|
||||
{ "wallet", "getwalletinfo", &getwalletinfo, false },
|
||||
{ "wallet", "importprivkey", &importprivkey, true },
|
||||
{ "wallet", "importwallet", &importwallet, true },
|
||||
{ "wallet", "importaddress", &importaddress, true },
|
||||
{ "wallet", "importpubkey", &importpubkey, true },
|
||||
{ "wallet", "keypoolrefill", &keypoolrefill, true },
|
||||
{ "wallet", "listaccounts", &listaccounts, false },
|
||||
{ "wallet", "listaddressgroupings", &listaddressgroupings, false },
|
||||
{ "wallet", "listlockunspent", &listlockunspent, false },
|
||||
{ "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false },
|
||||
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false },
|
||||
{ "wallet", "listsinceblock", &listsinceblock, false },
|
||||
{ "wallet", "listtransactions", &listtransactions, false },
|
||||
{ "wallet", "listunspent", &listunspent, false },
|
||||
{ "wallet", "lockunspent", &lockunspent, true },
|
||||
{ "wallet", "move", &movecmd, false },
|
||||
{ "wallet", "sendfrom", &sendfrom, false },
|
||||
{ "wallet", "sendmany", &sendmany, false },
|
||||
{ "wallet", "sendtoaddress", &sendtoaddress, false },
|
||||
{ "wallet", "setaccount", &setaccount, true },
|
||||
{ "wallet", "settxfee", &settxfee, true },
|
||||
{ "wallet", "signmessage", &signmessage, true },
|
||||
{ "wallet", "walletlock", &walletlock, true },
|
||||
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
|
||||
{ "wallet", "walletpassphrase", &walletpassphrase, true },
|
||||
#endif // ENABLE_WALLET
|
||||
};
|
||||
|
||||
CRPCTable::CRPCTable()
|
||||
@@ -396,6 +345,20 @@ const CRPCCommand *CRPCTable::operator[](const std::string &name) const
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
|
||||
{
|
||||
if (IsRPCRunning())
|
||||
return false;
|
||||
|
||||
// don't allow overwriting for now
|
||||
map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
|
||||
if (it != mapCommands.end())
|
||||
return false;
|
||||
|
||||
mapCommands[name] = pcmd;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartRPC()
|
||||
{
|
||||
LogPrint("rpc", "Starting RPC\n");
|
||||
@@ -573,4 +536,4 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
|
||||
deadlineTimers.insert(std::make_pair(name, boost::shared_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000))));
|
||||
}
|
||||
|
||||
const CRPCTable tableRPC;
|
||||
CRPCTable tableRPC;
|
||||
|
||||
Reference in New Issue
Block a user