Browse Source

Merge pull request #1493 from jgarzik/unlocked-rpc

RPC: add facility to enable RPCs to run outside cs_main, wallet locks
0.8
Jeff Garzik 12 years ago
parent
commit
1954d40691
  1. 120
      src/bitcoinrpc.cpp
  2. 1
      src/bitcoinrpc.h

120
src/bitcoinrpc.cpp

@ -191,62 +191,62 @@ Value stop(const Array& params, bool fHelp)
static const CRPCCommand vRPCCommands[] = static const CRPCCommand vRPCCommands[] =
{ // name function safe mode? { // name function safemd unlocked
// ------------------------ ----------------------- ---------- // ------------------------ ----------------------- ------ --------
{ "help", &help, true }, { "help", &help, true, true },
{ "stop", &stop, true }, { "stop", &stop, true, true },
{ "getblockcount", &getblockcount, true }, { "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true }, { "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true }, { "getpeerinfo", &getpeerinfo, true, false },
{ "getdifficulty", &getdifficulty, true }, { "getdifficulty", &getdifficulty, true, false },
{ "getgenerate", &getgenerate, true }, { "getgenerate", &getgenerate, true, false },
{ "setgenerate", &setgenerate, true }, { "setgenerate", &setgenerate, true, false },
{ "gethashespersec", &gethashespersec, true }, { "gethashespersec", &gethashespersec, true, false },
{ "getinfo", &getinfo, true }, { "getinfo", &getinfo, true, false },
{ "getmininginfo", &getmininginfo, true }, { "getmininginfo", &getmininginfo, true, false },
{ "getnewaddress", &getnewaddress, true }, { "getnewaddress", &getnewaddress, true, false },
{ "getaccountaddress", &getaccountaddress, true }, { "getaccountaddress", &getaccountaddress, true, false },
{ "setaccount", &setaccount, true }, { "setaccount", &setaccount, true, false },
{ "getaccount", &getaccount, false }, { "getaccount", &getaccount, false, false },
{ "getaddressesbyaccount", &getaddressesbyaccount, true }, { "getaddressesbyaccount", &getaddressesbyaccount, true, false },
{ "sendtoaddress", &sendtoaddress, false }, { "sendtoaddress", &sendtoaddress, false, false },
{ "getreceivedbyaddress", &getreceivedbyaddress, false }, { "getreceivedbyaddress", &getreceivedbyaddress, false, false },
{ "getreceivedbyaccount", &getreceivedbyaccount, false }, { "getreceivedbyaccount", &getreceivedbyaccount, false, false },
{ "listreceivedbyaddress", &listreceivedbyaddress, false }, { "listreceivedbyaddress", &listreceivedbyaddress, false, false },
{ "listreceivedbyaccount", &listreceivedbyaccount, false }, { "listreceivedbyaccount", &listreceivedbyaccount, false, false },
{ "backupwallet", &backupwallet, true }, { "backupwallet", &backupwallet, true, false },
{ "keypoolrefill", &keypoolrefill, true }, { "keypoolrefill", &keypoolrefill, true, false },
{ "walletpassphrase", &walletpassphrase, true }, { "walletpassphrase", &walletpassphrase, true, false },
{ "walletpassphrasechange", &walletpassphrasechange, false }, { "walletpassphrasechange", &walletpassphrasechange, false, false },
{ "walletlock", &walletlock, true }, { "walletlock", &walletlock, true, false },
{ "encryptwallet", &encryptwallet, false }, { "encryptwallet", &encryptwallet, false, false },
{ "validateaddress", &validateaddress, true }, { "validateaddress", &validateaddress, true, false },
{ "getbalance", &getbalance, false }, { "getbalance", &getbalance, false, false },
{ "move", &movecmd, false }, { "move", &movecmd, false, false },
{ "sendfrom", &sendfrom, false }, { "sendfrom", &sendfrom, false, false },
{ "sendmany", &sendmany, false }, { "sendmany", &sendmany, false, false },
{ "addmultisigaddress", &addmultisigaddress, false }, { "addmultisigaddress", &addmultisigaddress, false, false },
{ "getrawmempool", &getrawmempool, true }, { "getrawmempool", &getrawmempool, true, false },
{ "getblock", &getblock, false }, { "getblock", &getblock, false, false },
{ "getblockhash", &getblockhash, false }, { "getblockhash", &getblockhash, false, false },
{ "gettransaction", &gettransaction, false }, { "gettransaction", &gettransaction, false, false },
{ "listtransactions", &listtransactions, false }, { "listtransactions", &listtransactions, false, false },
{ "signmessage", &signmessage, false }, { "signmessage", &signmessage, false, false },
{ "verifymessage", &verifymessage, false }, { "verifymessage", &verifymessage, false, false },
{ "getwork", &getwork, true }, { "getwork", &getwork, true, false },
{ "listaccounts", &listaccounts, false }, { "listaccounts", &listaccounts, false, false },
{ "settxfee", &settxfee, false }, { "settxfee", &settxfee, false, false },
{ "getblocktemplate", &getblocktemplate, true }, { "getblocktemplate", &getblocktemplate, true, false },
{ "submitblock", &submitblock, false }, { "submitblock", &submitblock, false, false },
{ "listsinceblock", &listsinceblock, false }, { "listsinceblock", &listsinceblock, false, false },
{ "dumpprivkey", &dumpprivkey, false }, { "dumpprivkey", &dumpprivkey, false, false },
{ "importprivkey", &importprivkey, false }, { "importprivkey", &importprivkey, false, false },
{ "listunspent", &listunspent, false }, { "listunspent", &listunspent, false, false },
{ "getrawtransaction", &getrawtransaction, false }, { "getrawtransaction", &getrawtransaction, false, false },
{ "createrawtransaction", &createrawtransaction, false }, { "createrawtransaction", &createrawtransaction, false, false },
{ "decoderawtransaction", &decoderawtransaction, false }, { "decoderawtransaction", &decoderawtransaction, false, false },
{ "signrawtransaction", &signrawtransaction, false }, { "signrawtransaction", &signrawtransaction, false, false },
{ "sendrawtransaction", &sendrawtransaction, false }, { "sendrawtransaction", &sendrawtransaction, false, false },
}; };
CRPCTable::CRPCTable() CRPCTable::CRPCTable()
@ -1008,8 +1008,12 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
// Execute // Execute
Value result; Value result;
{ {
LOCK2(cs_main, pwalletMain->cs_wallet); if (pcmd->unlocked)
result = pcmd->actor(params, false); result = pcmd->actor(params, false);
else {
LOCK2(cs_main, pwalletMain->cs_wallet);
result = pcmd->actor(params, false);
}
} }
return result; return result;
} }

1
src/bitcoinrpc.h

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

Loading…
Cancel
Save