PRCYCoin  2.0.0.7rc1
P2P Digital Currency
server.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2015-2018 The PIVX developers
5 // Copyright (c) 2018-2020 The DAPS Project developers
6 // Distributed under the MIT software license, see the accompanying
7 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 
9 #include "rpc/server.h"
10 
11 #include "base58.h"
12 #include "fs.h"
13 #include "init.h"
14 #include "main.h"
15 #include "random.h"
16 #include "sync.h"
17 #include "guiinterface.h"
18 #include "util.h"
19 #include "utilstrencodings.h"
20 
21 #ifdef ENABLE_WALLET
22 #include "wallet/wallet.h"
23 #endif
24 
25 #include <boost/bind.hpp>
26 #include <boost/iostreams/concepts.hpp>
27 #include <boost/iostreams/stream.hpp>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/signals2/signal.hpp>
30 #include <boost/thread.hpp>
31 #include <boost/algorithm/string/case_conv.hpp> // for to_upper()
32 #include <univalue.h>
33 
34 
35 
36 static bool fRPCRunning = false;
37 static bool fRPCInWarmup = true;
38 static std::string rpcWarmupStatus("RPC server started");
39 static RecursiveMutex cs_rpcWarmup;
40 
41 /* Timer-creating functions */
42 static RPCTimerInterface* timerInterface = NULL;
43 /* Map of name to timer.
44  * @note Can be changed to std::unique_ptr when C++11 */
45 static std::map <std::string, boost::shared_ptr<RPCTimerBase>> deadlineTimers;
46 
47 static struct CRPCSignals {
48  boost::signals2::signal<void()> Started;
49  boost::signals2::signal<void()> Stopped;
50  boost::signals2::signal<void(const CRPCCommand &)> PreCommand;
51  boost::signals2::signal<void(const CRPCCommand &)> PostCommand;
52 } g_rpcSignals;
53 
54 void RPCServer::OnStarted(boost::function<void()> slot) {
55  g_rpcSignals.Started.connect(slot);
56 }
57 
58 void RPCServer::OnStopped(boost::function<void()> slot) {
59  g_rpcSignals.Stopped.connect(slot);
60 }
61 
62 void RPCServer::OnPreCommand(boost::function<void(const CRPCCommand &)> slot) {
63  g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
64 }
65 
66 void RPCServer::OnPostCommand(boost::function<void(const CRPCCommand &)> slot) {
67  g_rpcSignals.PostCommand.connect(boost::bind(slot, _1));
68 }
69 
70 void RPCTypeCheck(const UniValue &params, const std::list<UniValue::VType>& typesExpected, bool fAllowNull) {
71  unsigned int i = 0;
72  for (UniValue::VType t : typesExpected) {
73  if (params.size() <= i)
74  break;
75 
76  const UniValue& v = params[i];
77  if (!((v.type() == t) || (fAllowNull && (v.isNull())))) {
78  std::string err = strprintf("Expected type %s, got %s",
79  uvTypeName(t), uvTypeName(v.type()));
80  throw JSONRPCError(RPC_TYPE_ERROR, err);
81  }
82  i++;
83  }
84 }
85 
86 void RPCTypeCheckObj(const UniValue& o,
87  const std::map<std::string, UniValue::VType>& typesExpected,
88  bool fAllowNull)
89 {
90  for (const PAIRTYPE(std::string, UniValue::VType)& t : typesExpected) {
91  const UniValue& v = find_value(o, t.first);
92  if (!fAllowNull && v.isNull())
93  throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
94 
95  if (!((v.type() == t.second) || (fAllowNull && (v.isNull())))) {
96  std::string err = strprintf("Expected type %s for %s, got %s",
97  uvTypeName(t.second), t.first, uvTypeName(v.type()));
98  throw JSONRPCError(RPC_TYPE_ERROR, err);
99  }
100  }
101 }
102 
103 static inline int64_t roundint64(double d) {
104  return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
105 }
106 
108  if (!value.isNum())
109  throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number");
110 
111  double dAmount = value.get_real();
112  if (dAmount <= 0.0 || dAmount > MAX_MONEY_OUT)
113  throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
114  CAmount nAmount = roundint64(dAmount * COIN);
115  return nAmount;
116 }
117 
119  bool sign = amount < 0;
120  int64_t n_abs = (sign ? -amount : amount);
121  int64_t quotient = n_abs / COIN;
122  int64_t remainder = n_abs % COIN;
123  return UniValue(UniValue::VNUM,
124  strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder));
125 }
126 
127 uint256 ParseHashV(const UniValue& v, std::string strName) {
128  std::string strHex;
129  if (v.isStr())
130  strHex = v.get_str();
131  if (!IsHex(strHex)) // Note: IsHex("") is false
132  throw JSONRPCError(RPC_INVALID_PARAMETER, strName + " must be hexadecimal string (not '" + strHex + "')");
133  if (64 != strHex.length())
134  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d)", strName, 64, strHex.length()));
135  uint256 result;
136  result.SetHex(strHex);
137  return result;
138 }
139 
140 uint256 ParseHashO(const UniValue& o, std::string strKey) {
141  return ParseHashV(find_value(o, strKey), strKey);
142 }
143 
144 std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName) {
145  std::string strHex;
146  if (v.isStr())
147  strHex = v.get_str();
148  if (!IsHex(strHex))
149  throw JSONRPCError(RPC_INVALID_PARAMETER, strName + " must be hexadecimal string (not '" + strHex + "')");
150  return ParseHex(strHex);
151 }
152 
153 std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey) {
154  return ParseHexV(find_value(o, strKey), strKey);
155 }
156 
157 int ParseInt(const UniValue& o, std::string strKey) {
158  const UniValue &v = find_value(o, strKey);
159  if (!v.isNum())
160  throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, " + strKey + "is not an int");
161 
162  return v.get_int();
163 }
164 
165 bool ParseBool(const UniValue& o, std::string strKey) {
166  const UniValue& v = find_value(o, strKey);
167  if (!v.isBool())
168  throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, " + strKey + "is not a bool");
169 
170  return v.get_bool();
171 }
172 
173 
178 std::string CRPCTable::help(std::string strCommand) const {
179  std::string strRet;
180  std::string category;
181  std::set<rpcfn_type> setDone;
182  std::vector<std::pair<std::string, const CRPCCommand*> > vCommands;
183 
184  for (std::map<std::string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
185  vCommands.push_back(std::make_pair(mi->second->category + mi->first, mi->second));
186  std::sort(vCommands.begin(), vCommands.end());
187 
188  for (const PAIRTYPE(std::string, const CRPCCommand*) & command : vCommands) {
189  const CRPCCommand *pcmd = command.second;
190  std::string strMethod = pcmd->name;
191  // We already filter duplicates, but these deprecated screw up the sort order
192  if (strMethod.find("label") != std::string::npos)
193  continue;
194  if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
195  continue;
196 #ifdef ENABLE_WALLET
197  if (pcmd->reqWallet && !pwalletMain)
198  continue;
199 #endif
200 
201  try {
202  UniValue params;
203  rpcfn_type pfn = pcmd->actor;
204  if (setDone.insert(pfn).second)
205  (*pfn)(params, true);
206  } catch (const std::exception& e) {
207  // Help text is returned in an exception
208  std::string strHelp = std::string(e.what());
209  if (strCommand == "") {
210  if (strHelp.find('\n') != std::string::npos)
211  strHelp = strHelp.substr(0, strHelp.find('\n'));
212 
213  if (category != pcmd->category) {
214  if (!category.empty())
215  strRet += "\n";
216  category = pcmd->category;
217  std::string firstLetter = category.substr(0, 1);
218  boost::to_upper(firstLetter);
219  strRet += "== " + firstLetter + category.substr(1) + " ==\n";
220  }
221  }
222  strRet += strHelp + "\n";
223  }
224  }
225  if (strRet == "")
226  strRet = strprintf("help: unknown command: %s\n", strCommand);
227  strRet = strRet.substr(0, strRet.size() - 1);
228  return strRet;
229 }
230 
231 UniValue help(const UniValue& params, bool fHelp) {
232  if (fHelp || params.size() > 1)
233  throw std::runtime_error(
234  "help ( \"command\" )\n"
235  "\nList all commands, or get help for a specified command.\n"
236  "\nArguments:\n"
237  "1. \"command\" (string, optional) The command to get help on\n"
238  "\nResult:\n"
239  "\"text\" (string) The help text\n");
240 
241  std::string strCommand;
242  if (params.size() > 0)
243  strCommand = params[0].get_str();
244 
245  return tableRPC.help(strCommand);
246 }
247 
248 
249 UniValue stop(const UniValue& params, bool fHelp) {
250  // Accept the deprecated and ignored 'detach' boolean argument
251  if (fHelp || params.size() > 1)
252  throw std::runtime_error(
253  "stop\n"
254  "\nStop PRCY server.");
255  // Event loop will exit after current HTTP requests have been handled, so
256  // this reply will get back to the client.
257  StartShutdown();
258  return "PRCY server stopping";
259 }
260 
261 
265 static const CRPCCommand vRPCCommands[] =
266  {
267  // category name actor (function) okSafeMode threadSafe reqWallet
268  // --------------------- ------------------------ ----------------------- ---------- ---------- ---------
269  /* Overall control/query calls */
270  {"control", "getinfo", &getinfo, true, false, false}, /* uses wallet if enabled */
271  {"control", "getversion", &getversion, true, false, false},
272  {"control", "help", &help, true, true, false},
273  {"control", "stop", &stop, true, true, false},
274 
275  /* P2P networking */
276  {"network", "getnetworkinfo", &getnetworkinfo, true, false, false},
277  {"network", "addnode", &addnode, true, true, false},
278  {"network", "disconnectnode", &disconnectnode, true, true, false},
279  {"network", "getaddednodeinfo", &getaddednodeinfo, true, true, false},
280  {"network", "getconnectioncount", &getconnectioncount, true, false, false},
281  {"network", "getnettotals", &getnettotals, true, true, false},
282  {"network", "getpeerinfo", &getpeerinfo, true, false, false},
283  {"network", "ping", &ping, true, false, false},
284  {"network", "setban", &setban, true, false, false},
285  {"network", "listbanned", &listbanned, true, false, false},
286  {"network", "clearbanned", &clearbanned, true, false, false},
287 
288  /* Block chain and UTXO */
289  {"blockchain", "getsupply", &getsupply, true, false, false},
290  {"blockchain", "getmaxsupply", &getmaxsupply, true, false, false},
291  {"blockchain", "getblockchaininfo", &getblockchaininfo, true, false, false},
292  {"blockchain", "getbestblockhash", &getbestblockhash, true, false, false},
293  {"blockchain", "getblockcount", &getblockcount, true, false, false},
294  {"blockchain", "getblock", &getblock, true, false, false},
295  {"blockchain", "getblockhash", &getblockhash, true, false, false},
296  {"blockchain", "getblockindexstats", &getblockindexstats, true, false, false},
297  {"blockchain", "getlastpoablock", &getlastpoablock, true, false, false},
298  {"blockchain", "getlastpoablockhash", &getlastpoablockhash, true, false, false},
299  {"blockchain", "getlastpoablockheight", &getlastpoablockheight, true, false, false},
300  {"blockchain", "getlastpoablocktime", &getlastpoablocktime, true, false, false},
301  {"blockchain", "getlastpoaauditedpos", &getlastpoaauditedpos, true, false, false},
302  {"blockchain", "setmaxreorgdepth", &setmaxreorgdepth, true, false, false},
303  {"blockchain", "resyncfrom", &resyncfrom, true, false, false},
304  {"blockchain", "getblockheader", &getblockheader, false, false, false},
305  {"blockchain", "getchaintips", &getchaintips, true, false, false},
306  {"blockchain", "getdifficulty", &getdifficulty, true, false, false},
307  {"blockchain", "getfeeinfo", &getfeeinfo, true, false, false},
308  {"blockchain", "getmempoolinfo", &getmempoolinfo, true, true, false},
309  {"blockchain", "getrawmempool", &getrawmempool, true, false, false},
310  {"blockchain", "gettxout", &gettxout, true, false, false},
311  {"blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, false, false},
312  {"blockchain", "verifychain", &verifychain, true, false, false},
313  {"blockchain", "invalidateblock", &invalidateblock, true, true, false},
314  {"blockchain", "reconsiderblock", &reconsiderblock, true, true, false},
315  {"getinvalid", "getinvalid", &getinvalid, true, true, false},
316 
317  /* Mining */
318  {"mining", "getblocktemplate", &getblocktemplate, true, false, false},
319  {"mining", "getpoablocktemplate", &getpoablocktemplate, true, false, false},
320  {"mining", "setminingnbits", &setminingnbits, true, false, false},
321  {"mining", "getmininginfo", &getmininginfo, true, false, false},
322  {"mining", "getnetworkhashps", &getnetworkhashps, true, false, false},
323  {"mining", "prioritisetransaction", &prioritisetransaction, true, false, false},
324  {"mining", "submitblock", &submitblock, true, true, false},
325  {"mining", "reservebalance", &reservebalance, true, true, false},
326 
327 #ifdef ENABLE_WALLET
328  /* Coin generation */
329  {"generating", "getgenerate", &getgenerate, true, false, false},
330  {"generating", "gethashespersec", &gethashespersec, true, false, false},
331  {"generating", "setgenerate", &setgenerate, true, true, false},
332  {"generating", "generate", &generate, true, true, false},
333  {"generating", "generatepoa", &generatepoa, true, true, false},
334 #endif
335 
336  /* Raw transactions */
337  {"rawtransactions", "createrawtransaction", &createrawtransaction, true, false, false},
338  {"rawtransactions", "decoderawtransaction", &decoderawtransaction, true, false, false},
339  {"rawtransactions", "decodescript", &decodescript, true, false, false},
340  {"rawtransactions", "getrawtransaction", &getrawtransaction, true, false, false},
341  {"rawtransactions", "sendrawtransaction", &sendrawtransaction, false, false, false},
342  {"rawtransactions", "getrawtransactionbyblockheight", &getrawtransactionbyblockheight, true, false, false},
343  /* Utility functions */
344  //{"util", "createmultisig", &createmultisig, true, true, false},
345  {"util", "logging", &logging, true, false, false},
346  // {"util", "validateaddress", &validateaddress, true, false, false}, /* uses wallet if enabled */
347  {"util", "validatestealthaddress", &validatestealthaddress, true, false, false}, /* uses wallet if enabled */
348  // {"util", "verifymessage", &verifymessage, true, false, false},
349  //{"util", "estimatefee", &estimatefee, true, true, false},
350  // {"util", "estimatepriority", &estimatepriority, true, true, false},
351 
352  /* Not shown in help */
353  // {"hidden", "invalidateblock", &invalidateblock, true, true, false},
354  // {"hidden", "reconsiderblock", &reconsiderblock, true, true, false},
355  // {"hidden", "setmocktime", &setmocktime, true, false, false},
356  { "hidden", "waitfornewblock", &waitfornewblock, true, true, false},
357  { "hidden", "waitforblock", &waitforblock, true, true, false},
358  { "hidden", "waitforblockheight", &waitforblockheight, true, true, false},
359 
360  /* Prcycoin features */
361  {"prcycoin", "masternode", &masternode, true, true, false},
362  {"prcycoin", "listmasternodes", &listmasternodes, true, true, false},
363  {"prcycoin", "getmasternodecount", &getmasternodecount, true, true, false},
364  {"prcycoin", "getcurrentseesawreward", &getcurrentseesawreward, true, true, false},
365  {"prcycoin", "getseesawrewardratio", &getseesawrewardratio, true, true, false},
366  {"prcycoin", "getseesawrewardwithheight", &getseesawrewardwithheight, true, true, false},
367  {"prcycoin", "masternodecurrent", &masternodecurrent, true, true, false},
368  {"prcycoin", "startmasternode", &startmasternode, true, true, false},
369  {"prcycoin", "listmasternodeconf", &listmasternodeconf, true, true, false},
370  {"prcycoin", "getmasternodewinners", &getmasternodewinners, true, true, false},
371  {"prcycoin", "getmasternodescores", &getmasternodescores, true, true, false},
372  {"prcycoin", "createmasternodebroadcast", &createmasternodebroadcast, true, true, false},
373  {"prcycoin", "decodemasternodebroadcast", &decodemasternodebroadcast, true, true, false},
374  {"prcycoin", "relaymasternodebroadcast", &relaymasternodebroadcast, true, true, false},
375  {"prcycoin", "mnsync", &mnsync, true, true, false},
376 
377 #ifdef ENABLE_WALLET
378  /* Wallet */
379  // {"wallet", "addmultisigaddress", &addmultisigaddress, true, false, true},
380  {"wallet", "autocombinedust", &autocombinedust, false, false, true},
381  {"wallet", "backupwallet", &backupwallet, true, false, true},
382  // {"wallet", "dumpprivkey", &dumpprivkey, true, false, true},
383  // {"wallet", "dumpwallet", &dumpwallet, true, false, true},
384  // {"wallet", "bip38encrypt", &bip38encrypt, true, false, true},
385  // {"wallet", "bip38decrypt", &bip38decrypt, true, false, true},
386  {"wallet", "encryptwallet", &encryptwallet, true, false, true},
387  // {"wallet", "createprivacywallet", &createprivacywallet, true, false, true},
388  {"wallet", "createprivacyaccount", &createprivacyaccount, true, false, true},
389  {"wallet", "showstealthaddress", &showstealthaddress, true, false, true},
390  {"wallet", "getaccountaddress", &showstealthaddress, true, false, true},
391  {"wallet", "getstealthaddress", &showstealthaddress, true, false, true},
392  {"wallet", "importkeys", &importkeys, true, false, true},
393  {"wallet", "revealviewprivatekey", &revealviewprivatekey, true, false, true},
394  {"wallet", "revealspendprivatekey", &revealspendprivatekey, true, false, true},
395  {"wallet", "showtxprivatekeys", &showtxprivatekeys, true, false, true},
396  {"wallet", "rescan", &rescan, true, false, true},
397  {"wallet", "rescanwallettransactions", &rescanwallettransactions, true, false, true},
398  {"wallet", "erasewallettransactions", &erasewallettransactions, true, false, true},
399  {"wallet", "setdecoyconfirmation", &setdecoyconfirmation, true, false, true},
400  {"wallet", "getdecoyconfirmation", &getdecoyconfirmation, true, false, true},
401  {"wallet", "decodestealthaddress", &decodestealthaddress, true, false, true},
402  {"wallet", "sendtostealthaddress", &sendtostealthaddress, false, false, true},
403  {"wallet", "sendalltostealthaddress", &sendalltostealthaddress, false, false, true},
404  {"wallet", "getbalance", &getbalance, false, false, true},
405  {"wallet", "getbalances", &getbalances, false, false, true},
406  {"wallet", "generateintegratedaddress", &generateintegratedaddress, true, false, false},
407  {"wallet", "readmasteraccount", &readmasteraccount, true, false, false},
408  // {"wallet", "getnewaddress", &getnewaddress, true, false, true},
409  // {"wallet", "getrawchangeaddress", &getrawchangeaddress, true, false, true},
410  // {"wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, false, true},
411  // {"wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, false, true},
412  {"wallet", "getstakingstatus", &getstakingstatus, false, false, true},
413  // {"wallet", "getstakesplitthreshold", &getstakesplitthreshold, false, false, true},
414  {"wallet", "gettransaction", &gettransaction, false, false, true},
415  {"wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, false, true},
416  {"wallet", "getwalletinfo", &getwalletinfo, false, false, true},
417  {"wallet", "gettxcount", &gettxcount, false, false, true},
418  // {"wallet", "importprivkey", &importprivkey, true, false, true},
419  // {"wallet", "importwallet", &importwallet, true, false, true},
420  // {"wallet", "importaddress", &importaddress, true, false, true},
421  // {"wallet", "keypoolrefill", &keypoolrefill, true, false, true},
422  // {"wallet", "listaccounts", &listaccounts, false, false, true},
423  // {"wallet", "listaddressgroupings", &listaddressgroupings, false, false, true},
424  // {"wallet", "listlockunspent", &listlockunspent, false, false, true},
425  // {"wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, false, true},
426  // {"wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, false, true},
427  {"wallet", "listsinceblock", &listsinceblock, false, false, true},
428  {"wallet", "listtransactions", &listtransactions, false, false, true},
429  {"wallet", "listtransactionsbypaymentid", &listtransactionsbypaymentid, false, false, true},
430  {"wallet", "listunspent", &listunspent, false, false, true},
431  {"wallet", "getunspentcount", &getunspentcount, false, false, true},
432  // {"wallet", "lockunspent", &lockunspent, true, false, true},
433  // {"wallet", "move", &movecmd, false, false, true},
434  // {"wallet", "multisend", &multisend, false, false, true},
435  // {"wallet", "sendfrom", &sendfrom, false, false, true},
436  // {"wallet", "sendmany", &sendmany, false, false, true},
437  // {"wallet", "setaccount", &setaccount, true, false, true},
438  // {"wallet", "setstakesplitthreshold", &setstakesplitthreshold, false, false, true},
439  // {"wallet", "settxfee", &settxfee, true, false, true},
440  // {"wallet", "signmessage", &signmessage, true, false, true},
441  {"wallet", "walletlock", &walletlock, true, false, true},
442  {"wallet", "walletpassphrasechange", &walletpassphrasechange, true, false, true},
443  {"wallet", "unlockwallet", &unlockwallet, true, false, true},
444  {"wallet", "revealmnemonicphrase", &revealmnemonicphrase, true, false, true},
445  {"wallet", "createmasternode", &createmasternode, true, false, true},
446  {"wallet", "erasefromwallet", &erasefromwallet, true, false, true}
447 
448 #endif // ENABLE_WALLET
449  };
450 
452  unsigned int vcidx;
453  for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++) {
454  const CRPCCommand *pcmd;
455 
456  pcmd = &vRPCCommands[vcidx];
457  mapCommands[pcmd->name] = pcmd;
458  }
459 }
460 
461 const CRPCCommand *CRPCTable::operator[](const std::string &name) const {
462  std::map<std::string, const CRPCCommand *>::const_iterator it = mapCommands.find(name);
463  if (it == mapCommands.end())
464  return NULL;
465  return (*it).second;
466 }
467 
468 
469 bool StartRPC() {
470  LogPrint(BCLog::RPC, "Starting RPC\n");
471  fRPCRunning = true;
472  g_rpcSignals.Started();
473  return true;
474 }
475 
476 void InterruptRPC() {
477  LogPrint(BCLog::RPC, "Interrupting RPC\n");
478  // Interrupt e.g. running longpolls
479  // Interrupt e.g. running longpolls
480 }
481 
482 void StopRPC() {
483  LogPrint(BCLog::RPC, "Stopping RPC\n");
484  deadlineTimers.clear();
485 }
486 
487 bool IsRPCRunning() {
488  return fRPCRunning;
489 }
490 
491 void SetRPCWarmupStatus(const std::string &newStatus) {
492  LOCK(cs_rpcWarmup);
493  rpcWarmupStatus = newStatus;
494 }
495 
497  LOCK(cs_rpcWarmup);
498  assert(fRPCInWarmup);
499  fRPCInWarmup = false;
500 }
501 
502 bool RPCIsInWarmup(std::string *outStatus) {
503  LOCK(cs_rpcWarmup);
504  if (outStatus)
505  *outStatus = rpcWarmupStatus;
506  return fRPCInWarmup;
507 }
508 
509 void JSONRequest::parse(const UniValue& valRequest)
510 {
511  // Parse request
512  if (!valRequest.isObject())
513  throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
514  const UniValue& request = valRequest.get_obj();
515 
516  // Parse id now so errors from here on will have the id
517  id = find_value(request, "id");
518 
519  // Parse method
520  UniValue valMethod = find_value(request, "method");
521  if (valMethod.isNull())
522  throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
523  if (!valMethod.isStr())
524  throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
525  strMethod = valMethod.get_str();
526  if (strMethod != "getblocktemplate")
527  LogPrint(BCLog::RPC, "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
528 
529  // Parse params
530  UniValue valParams = find_value(request, "params");
531  if (valParams.isArray())
532  params = valParams.get_array();
533  else if (valParams.isNull())
535  else
536  throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
537 }
538 
539 
540 
541 static UniValue JSONRPCExecOne(const UniValue& req)
542 {
543  UniValue rpc_result(UniValue::VOBJ);
544 
545  JSONRequest jreq;
546  try {
547  jreq.parse(req);
548 
549  UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
550  rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
551  } catch (const UniValue& objError) {
552  rpc_result = JSONRPCReplyObj(NullUniValue, objError, jreq.id);
553  } catch (const std::exception& e) {
554  rpc_result = JSONRPCReplyObj(NullUniValue,
555  JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
556  }
557 
558  return rpc_result;
559 }
560 
561 std::string JSONRPCExecBatch(const UniValue &vReq) {
563  for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
564  ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
565 
566  return ret.write() + "\n";
567 }
568 
569 UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const {
570  // Return immediately if in warmup
571  std::string strWarmupStatus;
572  if (RPCIsInWarmup(&strWarmupStatus)) {
573  throw JSONRPCError(RPC_IN_WARMUP, "RPC in warm-up: " + strWarmupStatus);
574  }
575 
576  // Find method
577  const CRPCCommand *pcmd = tableRPC[strMethod];
578  if (!pcmd)
579  throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
580 
581 
582  g_rpcSignals.PreCommand(*pcmd);
583 
584  try {
585  return pcmd->actor(params, false);
586  } catch (const std::exception& e) {
587  throw JSONRPCError(RPC_MISC_ERROR, e.what());
588  }
589 
590  g_rpcSignals.PostCommand(*pcmd);
591 }
592 
593 std::vector <std::string> CRPCTable::listCommands() const {
594  std::vector <std::string> commandList;
595  typedef std::map<std::string, const CRPCCommand *> commandMap;
596 
597  std::transform(mapCommands.begin(), mapCommands.end(),
598  std::back_inserter(commandList),
599  boost::bind(&commandMap::value_type::first, _1));
600  return commandList;
601 }
602 
603 std::string HelpExampleCli(std::string methodname, std::string args) {
604  return "> prcycoin-cli " + methodname + " " + args + "\n";
605 }
606 
607 std::string HelpExampleRpc(std::string methodname, std::string args) {
608  return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", "
609  "\"method\": \"" +
610  methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:59683/\n";
611 }
612 
614  if (!timerInterface)
615  timerInterface = iface;
616 }
617 
619  timerInterface = iface;
620 }
621 
623  if (timerInterface == iface)
624  timerInterface = NULL;
625 }
626 
627 void RPCRunLater(const std::string &name, boost::function<void(void)> func, int64_t nSeconds) {
628  if (!timerInterface)
629  throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
630  deadlineTimers.erase(name);
631  LogPrint(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name());
632  deadlineTimers.insert(
633  std::make_pair(name, boost::shared_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds * 1000))));
634 }
635 
RPC_METHOD_NOT_FOUND
@ RPC_METHOD_NOT_FOUND
Definition: protocol.h:34
RPC_INVALID_REQUEST
@ RPC_INVALID_REQUEST
Standard JSON-RPC 2.0 errors.
Definition: protocol.h:33
RPC_MISC_ERROR
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:40
disconnectnode
UniValue disconnectnode(const UniValue &params, bool fHelp)
Definition: net.cpp:204
getblockindexstats
UniValue getblockindexstats(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1392
setban
UniValue setban(const UniValue &params, bool fHelp)
Definition: net.cpp:394
invalidateblock
UniValue invalidateblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:986
getblockcount
UniValue getblockcount(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:194
UniValue::isBool
bool isBool() const
Definition: univalue.h:80
createmasternode
UniValue createmasternode(const UniValue &params, bool fHelp)
Definition: masternode.cpp:497
ParseInt
int ParseInt(const UniValue &o, std::string strKey)
Definition: server.cpp:157
getbestblockhash
UniValue getbestblockhash(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:209
createrawtransaction
UniValue createrawtransaction(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:557
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:21
getlastpoaauditedpos
UniValue getlastpoaauditedpos(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1328
getversion
UniValue getversion(const UniValue &params, bool fHelp)
Definition: misc.cpp:136
UniValue::get_bool
bool get_bool() const
Definition: univalue.cpp:302
getlastpoablock
UniValue getlastpoablock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1224
getrawtransaction
UniValue getrawtransaction(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:252
rescanwallettransactions
UniValue rescanwallettransactions(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:3036
RPC_INTERNAL_ERROR
@ RPC_INTERNAL_ERROR
Definition: protocol.h:36
getblocktemplate
UniValue getblocktemplate(const UniValue &params, bool fHelp)
Definition: mining.cpp:405
getmaxsupply
UniValue getmaxsupply(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:180
rescan
UniValue rescan(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:3014
masternodecurrent
UniValue masternodecurrent(const UniValue &params, bool fHelp)
Definition: masternode.cpp:274
getrawmempool
UniValue getrawmempool(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:423
getpoablocktemplate
UniValue getpoablocktemplate(const UniValue &params, bool fHelp)
Definition: mining.cpp:690
getpeerinfo
UniValue getpeerinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:72
fs.h
listtransactions
UniValue listtransactions(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1227
getchaintips
UniValue getchaintips(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:830
createprivacyaccount
UniValue createprivacyaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2540
StartShutdown
void StartShutdown()
Definition: init.cpp:131
revealviewprivatekey
UniValue revealviewprivatekey(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2947
gettransaction
UniValue gettransaction(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1610
ParseHex
std::vector< unsigned char > ParseHex(const char *psz)
Definition: utilstrencodings.cpp:77
walletlock
UniValue walletlock(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1852
RPCTimerInterface
RPC timer "driver".
Definition: server.h:88
gettxout
UniValue gettxout(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:635
getmasternodewinners
UniValue getmasternodewinners(const UniValue &params, bool fHelp)
Definition: masternode.cpp:709
getnetworkinfo
UniValue getnetworkinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:332
ValueFromAmount
UniValue ValueFromAmount(const CAmount &amount)
Definition: server.cpp:118
JSONRPCReplyObj
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: protocol.cpp:42
sync.h
UniValue::VType
VType
Definition: univalue.h:21
getblock
UniValue getblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:486
RPCUnsetTimerInterface
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
Definition: server.cpp:622
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:78
decodemasternodebroadcast
UniValue decodemasternodebroadcast(const UniValue &params, bool fHelp)
Definition: masternode.cpp:1080
getlastpoablocktime
UniValue getlastpoablocktime(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1301
InterruptRPC
void InterruptRPC()
Definition: server.cpp:476
tableRPC
const CRPCTable tableRPC
Definition: server.cpp:636
RPC_INVALID_PARAMETER
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
Definition: protocol.h:45
sendrawtransaction
UniValue sendrawtransaction(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:1027
wallet.h
generateintegratedaddress
UniValue generateintegratedaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2608
encryptwallet
UniValue encryptwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1882
masternode
UniValue masternode(const UniValue &params, bool fHelp)
Definition: masternode.cpp:24
JSONRequest::id
UniValue id
Definition: server.h:40
getunconfirmedbalance
UniValue getunconfirmedbalance(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:692
AnnotatedMixin< std::recursive_mutex >
JSONRequest
Definition: server.h:37
getmininginfo
UniValue getmininginfo(const UniValue &params, bool fHelp)
Definition: mining.cpp:312
UniValue::isNull
bool isNull() const
Definition: univalue.h:77
sendalltostealthaddress
UniValue sendalltostealthaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2857
createmasternodebroadcast
UniValue createmasternodebroadcast(const UniValue &params, bool fHelp)
Definition: masternode.cpp:971
RPCTypeCheck
void RPCTypeCheck(const UniValue &params, const std::list< UniValue::VType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Definition: server.cpp:70
SanitizeString
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
Definition: utilstrencodings.cpp:32
guiinterface.h
UniValue::isNum
bool isNum() const
Definition: univalue.h:82
decodestealthaddress
UniValue decodestealthaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2761
sendtostealthaddress
UniValue sendtostealthaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2797
getmempoolinfo
UniValue getmempoolinfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:969
getmasternodecount
UniValue getmasternodecount(const UniValue &params, bool fHelp)
Definition: masternode.cpp:237
startmasternode
UniValue startmasternode(const UniValue &params, bool fHelp)
Definition: masternode.cpp:366
prioritisetransaction
UniValue prioritisetransaction(const UniValue &params, bool fHelp)
Definition: mining.cpp:357
ParseBool
bool ParseBool(const UniValue &o, std::string strKey)
Definition: server.cpp:165
getnetworkhashps
UniValue getnetworkhashps(const UniValue &params, bool fHelp)
Definition: mining.cpp:77
getseesawrewardwithheight
UniValue getseesawrewardwithheight(const UniValue &params, bool fHelp)
Definition: masternode.cpp:888
IsRPCRunning
bool IsRPCRunning()
Definition: server.cpp:487
UniValue
Definition: univalue.h:19
JSONRequest::params
UniValue params
Definition: server.h:42
listmasternodeconf
UniValue listmasternodeconf(const UniValue &params, bool fHelp)
Definition: masternode.cpp:607
ping
UniValue ping(const UniValue &params, bool fHelp)
Definition: net.cpp:39
JSONRPCExecBatch
std::string JSONRPCExecBatch(const UniValue &vReq)
Definition: server.cpp:561
UniValue::type
enum VType type() const
Definition: univalue.h:168
showtxprivatekeys
UniValue showtxprivatekeys(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2987
BCLog::RPC
@ RPC
Definition: logging.h:47
erasefromwallet
UniValue erasefromwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:3128
UniValue::get_str
const std::string & get_str() const
Definition: univalue.cpp:309
SetRPCWarmupFinished
void SetRPCWarmupFinished()
Definition: server.cpp:496
UniValue::isStr
bool isStr() const
Definition: univalue.h:81
CRPCTable::help
std::string help(std::string name) const
Note: This interface may still be subject to change.
Definition: server.cpp:178
SetRPCWarmupStatus
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
Definition: server.cpp:491
getbalances
UniValue getbalances(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:666
CRPCTable::CRPCTable
CRPCTable()
Definition: server.cpp:451
readmasteraccount
UniValue readmasteraccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2742
reconsiderblock
UniValue reconsiderblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1057
random.h
getbalance
UniValue getbalance(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:597
getmasternodescores
UniValue getmasternodescores(const UniValue &params, bool fHelp)
Definition: masternode.cpp:810
UniValue::get_obj
const UniValue & get_obj() const
Definition: univalue.cpp:346
gettxcount
UniValue gettxcount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2110
CRPCTable::execute
UniValue execute(const std::string &method, const UniValue &params) const
Execute a method.
Definition: server.cpp:569
IsHex
bool IsHex(const std::string &str)
Definition: utilstrencodings.cpp:68
listbanned
UniValue listbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:449
walletpassphrasechange
UniValue walletpassphrasechange(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1811
clearbanned
UniValue clearbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:475
getblockchaininfo
UniValue getblockchaininfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:767
RPCTypeCheckObj
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValue::VType > &typesExpected, bool fAllowNull)
Check for expected keys/value types in an Object.
Definition: server.cpp:86
addnode
UniValue addnode(const UniValue &params, bool fHelp)
Definition: net.cpp:160
RPCSetTimerInterfaceIfUnset
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set factory function for timers, but only if unset.
Definition: server.cpp:613
CRPCCommand
Definition: server.h:118
ParseHexV
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
Definition: server.cpp:144
init.h
decoderawtransaction
UniValue decoderawtransaction(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:658
revealmnemonicphrase
UniValue revealmnemonicphrase(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:3104
revealspendprivatekey
UniValue revealspendprivatekey(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2967
RPCServer::OnStopped
void OnStopped(boost::function< void()> slot)
Definition: server.cpp:58
resyncfrom
UniValue resyncfrom(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1022
univalue.h
RPCRunLater
void RPCRunLater(const std::string &name, boost::function< void(void)> func, int64_t nSeconds)
Run func nSeconds from now.
Definition: server.cpp:627
relaymasternodebroadcast
UniValue relaymasternodebroadcast(const UniValue &params, bool fHelp)
Definition: masternode.cpp:1140
reservebalance
UniValue reservebalance(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2131
PAIRTYPE
#define PAIRTYPE(t1, t2)
This is needed because the foreach macro can't get over the comma in pair<t1, t2>
Definition: utilstrencodings.h:24
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: protocol.cpp:60
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CRPCTable::listCommands
std::vector< std::string > listCommands() const
Returns a list of registered commands.
Definition: server.cpp:593
waitfornewblock
UniValue waitfornewblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:234
waitforblockheight
UniValue waitforblockheight(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:319
RPC_IN_WARMUP
@ RPC_IN_WARMUP
Transaction already in chain.
Definition: protocol.h:51
CRPCCommand::actor
rpcfn_type actor
Definition: server.h:123
setdecoyconfirmation
UniValue setdecoyconfirmation(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2892
validatestealthaddress
UniValue validatestealthaddress(const UniValue &params, bool fHelp)
Definition: misc.cpp:326
autocombinedust
UniValue autocombinedust(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2236
logging
UniValue logging(const UniValue &params, bool fHelp)
Definition: misc.cpp:544
uvTypeName
const char * uvTypeName(UniValue::VType t)
Definition: univalue.cpp:264
HelpExampleRpc
std::string HelpExampleRpc(std::string methodname, std::string args)
Definition: server.cpp:607
UniValue::VNUM
@ VNUM
Definition: univalue.h:21
generatepoa
UniValue generatepoa(const UniValue &params, bool fHelp)
getcurrentseesawreward
UniValue getcurrentseesawreward(const UniValue &params, bool fHelp)
Definition: masternode.cpp:857
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
importkeys
UniValue importkeys(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2636
RPCTimerInterface::NewTimer
virtual RPCTimerBase * NewTimer(boost::function< void(void)> &func, int64_t millis)=0
Factory function for timers.
base_uint::SetHex
void SetHex(const char *psz)
Definition: arith_uint256.cpp:164
erasewallettransactions
UniValue erasewallettransactions(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:3062
AmountFromValue
CAmount AmountFromValue(const UniValue &value)
Definition: server.cpp:107
listmasternodes
UniValue listmasternodes(const UniValue &params, bool fHelp)
Definition: masternode.cpp:153
JSONRequest::parse
void parse(const UniValue &valRequest)
Definition: server.cpp:509
LogPrint
#define LogPrint(category,...)
Definition: logging.h:162
UniValue::isArray
bool isArray() const
Definition: univalue.h:83
ParseHashV
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
Definition: server.cpp:127
CRPCCommand::category
std::string category
Definition: server.h:121
setminingnbits
UniValue setminingnbits(const UniValue &params, bool fHelp)
Definition: mining.cpp:871
unlockwallet
UniValue unlockwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1743
getblockhash
UniValue getblockhash(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:463
getlastpoablockhash
UniValue getlastpoablockhash(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1251
RPCTimerInterface::Name
virtual const char * Name()=0
Implementation name.
getinfo
UniValue getinfo(const UniValue &params, bool fHelp)
Definition: misc.cpp:45
getgenerate
UniValue getgenerate(const UniValue &params, bool fHelp)
CRPCTable
PRCY RPC command dispatcher.
Definition: server.h:132
HelpExampleCli
std::string HelpExampleCli(std::string methodname, std::string args)
Definition: server.cpp:603
name
const char * name
Definition: rest.cpp:34
RPCServer::OnStarted
void OnStarted(boost::function< void()> slot)
Definition: server.cpp:54
getnettotals
UniValue getnettotals(const UniValue &params, bool fHelp)
Definition: net.cpp:289
StartRPC
bool StartRPC()
Definition: server.cpp:469
getaddednodeinfo
UniValue getaddednodeinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:223
getwalletinfo
UniValue getwalletinfo(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2071
getlastpoablockheight
UniValue getlastpoablockheight(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1276
verifychain
UniValue verifychain(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:712
strprintf
#define strprintf
Definition: tinyformat.h:1056
JSONRequest::strMethod
std::string strMethod
Definition: server.h:41
getseesawrewardratio
UniValue getseesawrewardratio(const UniValue &params, bool fHelp)
Definition: masternode.cpp:924
UniValue::get_int
int get_int() const
Definition: univalue.cpp:316
showstealthaddress
UniValue showstealthaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2589
help
UniValue help(const UniValue &params, bool fHelp)
Definition: server.cpp:231
setmaxreorgdepth
UniValue setmaxreorgdepth(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1201
main.h
LOCK
#define LOCK(cs)
Definition: sync.h:182
gethashespersec
UniValue gethashespersec(const UniValue &params, bool fHelp)
listunspent
UniValue listunspent(const UniValue &params, bool fHelp)
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:173
stop
UniValue stop(const UniValue &params, bool fHelp)
Definition: server.cpp:249
rpcfn_type
UniValue(* rpcfn_type)(const UniValue &params, bool fHelp)
Definition: server.h:116
ParseHexO
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string strKey)
Definition: server.cpp:153
CRPCTable::mapCommands
std::map< std::string, const CRPCCommand * > mapCommands
Definition: server.h:135
UniValue::get_real
double get_real() const
Definition: univalue.cpp:336
base58.h
UniValue::size
size_t size() const
Definition: univalue.h:69
listtransactionsbypaymentid
UniValue listtransactionsbypaymentid(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1345
RPCServer::OnPreCommand
void OnPreCommand(boost::function< void(const CRPCCommand &)> slot)
Definition: server.cpp:62
getsupply
UniValue getsupply(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:165
utilstrencodings.h
find_value
const UniValue & find_value(const UniValue &obj, const std::string &name)
Definition: univalue.cpp:279
RPC_TYPE_ERROR
@ RPC_TYPE_ERROR
Server is in safe mode, and command is not allowed in safe mode.
Definition: protocol.h:42
getconnectioncount
UniValue getconnectioncount(const UniValue &params, bool fHelp)
Definition: net.cpp:24
RPCIsInWarmup
bool RPCIsInWarmup(std::string *outStatus)
Definition: server.cpp:502
gettxoutsetinfo
UniValue gettxoutsetinfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:599
mnsync
UniValue mnsync(const UniValue &params, bool fHelp)
Definition: misc.cpp:154
waitforblock
UniValue waitforblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:274
UniValue::get_array
const UniValue & get_array() const
Definition: univalue.cpp:353
UniValue::VARR
@ VARR
Definition: univalue.h:21
getunspentcount
UniValue getunspentcount(const UniValue &params, bool fHelp)
CRPCCommand::reqWallet
bool reqWallet
Definition: server.h:126
server.h
generate
UniValue generate(const UniValue &params, bool fHelp)
pwalletMain
CWallet * pwalletMain
Definition: wallet.cpp:49
StopRPC
void StopRPC()
Definition: server.cpp:482
CRPCTable::operator[]
const CRPCCommand * operator[](const std::string &name) const
Definition: server.cpp:461
getstakingstatus
UniValue getstakingstatus(const UniValue &params, bool fHelp)
getdecoyconfirmation
UniValue getdecoyconfirmation(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2920
getrawtransactionbyblockheight
UniValue getrawtransactionbyblockheight(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:200
getblockheader
UniValue getblockheader(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:548
RPC_PARSE_ERROR
@ RPC_PARSE_ERROR
Definition: protocol.h:37
RPCServer::OnPostCommand
void OnPostCommand(boost::function< void(const CRPCCommand &)> slot)
Definition: server.cpp:66
backupwallet
UniValue backupwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1682
UniValue::write
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
Definition: univalue_write.cpp:31
getinvalid
UniValue getinvalid(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:1094
getdifficulty
UniValue getdifficulty(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:364
CRPCCommand::name
std::string name
Definition: server.h:122
RPCSetTimerInterface
void RPCSetTimerInterface(RPCTimerInterface *iface)
Set factory function for timers.
Definition: server.cpp:618
listsinceblock
UniValue listsinceblock(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1527
getfeeinfo
UniValue getfeeinfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:919
UniValue::isObject
bool isObject() const
Definition: univalue.h:84
decodescript
UniValue decodescript(const UniValue &params, bool fHelp)
Definition: rawtransaction.cpp:722
ParseHashO
uint256 ParseHashO(const UniValue &o, std::string strKey)
Definition: server.cpp:140
submitblock
UniValue submitblock(const UniValue &params, bool fHelp)
Definition: mining.cpp:906
setgenerate
UniValue setgenerate(const UniValue &params, bool fHelp)