Dash Core  0.12.2.1
P2P Digital Currency
server.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 The Bitcoin Core developers
3 // Copyright (c) 2014-2017 The Dash Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #include "rpc/server.h"
8 
9 #include "base58.h"
10 #include "init.h"
11 #include "random.h"
12 #include "sync.h"
13 #include "ui_interface.h"
14 #include "util.h"
15 #include "utilstrencodings.h"
16 
17 #include <univalue.h>
18 
19 #include <boost/bind.hpp>
20 #include <boost/filesystem.hpp>
21 #include <boost/foreach.hpp>
22 #include <boost/iostreams/concepts.hpp>
23 #include <boost/iostreams/stream.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/signals2/signal.hpp>
26 #include <boost/thread.hpp>
27 #include <boost/algorithm/string/case_conv.hpp> // for to_upper()
28 
29 using namespace RPCServer;
30 using namespace std;
31 
32 static bool fRPCRunning = false;
33 static bool fRPCInWarmup = true;
34 static std::string rpcWarmupStatus("RPC server started");
36 /* Timer-creating functions */
37 static std::vector<RPCTimerInterface*> timerInterfaces;
38 /* Map of name to timer.
39  * @note Can be changed to std::unique_ptr when C++11 */
40 static std::map<std::string, boost::shared_ptr<RPCTimerBase> > deadlineTimers;
41 
42 static struct CRPCSignals
43 {
44  boost::signals2::signal<void ()> Started;
45  boost::signals2::signal<void ()> Stopped;
46  boost::signals2::signal<void (const CRPCCommand&)> PreCommand;
47  boost::signals2::signal<void (const CRPCCommand&)> PostCommand;
48 } g_rpcSignals;
49 
50 void RPCServer::OnStarted(boost::function<void ()> slot)
51 {
52  g_rpcSignals.Started.connect(slot);
53 }
54 
55 void RPCServer::OnStopped(boost::function<void ()> slot)
56 {
57  g_rpcSignals.Stopped.connect(slot);
58 }
59 
60 void RPCServer::OnPreCommand(boost::function<void (const CRPCCommand&)> slot)
61 {
62  g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
63 }
64 
65 void RPCServer::OnPostCommand(boost::function<void (const CRPCCommand&)> slot)
66 {
67  g_rpcSignals.PostCommand.connect(boost::bind(slot, _1));
68 }
69 
70 void RPCTypeCheck(const UniValue& params,
71  const list<UniValue::VType>& typesExpected,
72  bool fAllowNull)
73 {
74  unsigned int i = 0;
75  BOOST_FOREACH(UniValue::VType t, typesExpected)
76  {
77  if (params.size() <= i)
78  break;
79 
80  const UniValue& v = params[i];
81  if (!((v.type() == t) || (fAllowNull && (v.isNull()))))
82  {
83  string err = strprintf("Expected type %s, got %s",
84  uvTypeName(t), uvTypeName(v.type()));
86  }
87  i++;
88  }
89 }
90 
91 void RPCTypeCheckObj(const UniValue& o,
92  const map<string, UniValue::VType>& typesExpected,
93  bool fAllowNull)
94 {
95  BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected)
96  {
97  const UniValue& v = find_value(o, t.first);
98  if (!fAllowNull && v.isNull())
99  throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
100 
101  if (!((v.type() == t.second) || (fAllowNull && (v.isNull()))))
102  {
103  string err = strprintf("Expected type %s for %s, got %s",
104  uvTypeName(t.second), t.first, uvTypeName(v.type()));
106  }
107  }
108 }
109 
111 {
112  if (!value.isNum() && !value.isStr())
113  throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string");
114  CAmount amount;
115  if (!ParseFixedPoint(value.getValStr(), 8, &amount))
116  throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
117  if (!MoneyRange(amount))
118  throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range");
119  return amount;
120 }
121 
123 {
124  bool sign = amount < 0;
125  int64_t n_abs = (sign ? -amount : amount);
126  int64_t quotient = n_abs / COIN;
127  int64_t remainder = n_abs % COIN;
128  return UniValue(UniValue::VNUM,
129  strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder));
130 }
131 
132 uint256 ParseHashV(const UniValue& v, string strName)
133 {
134  string strHex;
135  if (v.isStr())
136  strHex = v.get_str();
137  if (!IsHex(strHex)) // Note: IsHex("") is false
138  throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
139  uint256 result;
140  result.SetHex(strHex);
141  return result;
142 }
143 uint256 ParseHashO(const UniValue& o, string strKey)
144 {
145  return ParseHashV(find_value(o, strKey), strKey);
146 }
147 vector<unsigned char> ParseHexV(const UniValue& v, string strName)
148 {
149  string strHex;
150  if (v.isStr())
151  strHex = v.get_str();
152  if (!IsHex(strHex))
153  throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
154  return ParseHex(strHex);
155 }
156 vector<unsigned char> ParseHexO(const UniValue& o, string strKey)
157 {
158  return ParseHexV(find_value(o, strKey), strKey);
159 }
160 
165 std::string CRPCTable::help(const std::string& strCommand) const
166 {
167  string strRet;
168  string category;
169  set<rpcfn_type> setDone;
170  vector<pair<string, const CRPCCommand*> > vCommands;
171 
172  for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
173  vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
174  sort(vCommands.begin(), vCommands.end());
175 
176  BOOST_FOREACH(const PAIRTYPE(string, const CRPCCommand*)& command, vCommands)
177  {
178  const CRPCCommand *pcmd = command.second;
179  string strMethod = pcmd->name;
180  // We already filter duplicates, but these deprecated screw up the sort order
181  if (strMethod.find("label") != string::npos)
182  continue;
183  if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
184  continue;
185  try
186  {
187  UniValue params;
188  rpcfn_type pfn = pcmd->actor;
189  if (setDone.insert(pfn).second)
190  (*pfn)(params, true);
191  }
192  catch (const std::exception& e)
193  {
194  // Help text is returned in an exception
195  string strHelp = string(e.what());
196  if (strCommand == "")
197  {
198  if (strHelp.find('\n') != string::npos)
199  strHelp = strHelp.substr(0, strHelp.find('\n'));
200 
201  if (category != pcmd->category)
202  {
203  if (!category.empty())
204  strRet += "\n";
205  category = pcmd->category;
206  string firstLetter = category.substr(0,1);
207  boost::to_upper(firstLetter);
208  strRet += "== " + firstLetter + category.substr(1) + " ==\n";
209  }
210  }
211  strRet += strHelp + "\n";
212  }
213  }
214  if (strRet == "")
215  strRet = strprintf("help: unknown command: %s\n", strCommand);
216  strRet = strRet.substr(0,strRet.size()-1);
217  return strRet;
218 }
219 
220 UniValue help(const UniValue& params, bool fHelp)
221 {
222  if (fHelp || params.size() > 1)
223  throw runtime_error(
224  "help ( \"command\" )\n"
225  "\nList all commands, or get help for a specified command.\n"
226  "\nArguments:\n"
227  "1. \"command\" (string, optional) The command to get help on\n"
228  "\nResult:\n"
229  "\"text\" (string) The help text\n"
230  );
231 
232  string strCommand;
233  if (params.size() > 0)
234  strCommand = params[0].get_str();
235 
236  return tableRPC.help(strCommand);
237 }
238 
239 
240 UniValue stop(const UniValue& params, bool fHelp)
241 {
242  // Accept the deprecated and ignored 'detach' boolean argument
243  if (fHelp || params.size() > 1)
244  throw runtime_error(
245  "stop\n"
246  "\nStop Dash Core server.");
247  // Event loop will exit after current HTTP requests have been handled, so
248  // this reply will get back to the client.
249  StartShutdown();
250  return "Dash Core server stopping";
251 }
252 
256 static const CRPCCommand vRPCCommands[] =
257 { // category name actor (function) okSafeMode
258  // --------------------- ------------------------ ----------------------- ----------
259  /* Overall control/query calls */
260  { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
261  { "control", "debug", &debug, true },
262  { "control", "help", &help, true },
263  { "control", "stop", &stop, true },
264 
265  /* P2P networking */
266  { "network", "getnetworkinfo", &getnetworkinfo, true },
267  { "network", "addnode", &addnode, true },
268  { "network", "disconnectnode", &disconnectnode, true },
269  { "network", "getaddednodeinfo", &getaddednodeinfo, true },
270  { "network", "getconnectioncount", &getconnectioncount, true },
271  { "network", "getnettotals", &getnettotals, true },
272  { "network", "getpeerinfo", &getpeerinfo, true },
273  { "network", "ping", &ping, true },
274  { "network", "setban", &setban, true },
275  { "network", "listbanned", &listbanned, true },
276  { "network", "clearbanned", &clearbanned, true },
277  { "network", "setnetworkactive", &setnetworkactive, true },
278 
279  /* Block chain and UTXO */
280  { "blockchain", "getblockchaininfo", &getblockchaininfo, true },
281  { "blockchain", "getbestblockhash", &getbestblockhash, true },
282  { "blockchain", "getblockcount", &getblockcount, true },
283  { "blockchain", "getblock", &getblock, true },
284  { "blockchain", "getblockhashes", &getblockhashes, true },
285  { "blockchain", "getblockhash", &getblockhash, true },
286  { "blockchain", "getblockheader", &getblockheader, true },
287  { "blockchain", "getblockheaders", &getblockheaders, true },
288  { "blockchain", "getchaintips", &getchaintips, true },
289  { "blockchain", "getdifficulty", &getdifficulty, true },
290  { "blockchain", "getmempoolinfo", &getmempoolinfo, true },
291  { "blockchain", "getrawmempool", &getrawmempool, true },
292  { "blockchain", "gettxout", &gettxout, true },
293  { "blockchain", "gettxoutproof", &gettxoutproof, true },
294  { "blockchain", "verifytxoutproof", &verifytxoutproof, true },
295  { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
296  { "blockchain", "verifychain", &verifychain, true },
297  { "blockchain", "getspentinfo", &getspentinfo, false },
298 
299  /* Mining */
300  { "mining", "getblocktemplate", &getblocktemplate, true },
301  { "mining", "getmininginfo", &getmininginfo, true },
302  { "mining", "getnetworkhashps", &getnetworkhashps, true },
303  { "mining", "prioritisetransaction", &prioritisetransaction, true },
304  { "mining", "submitblock", &submitblock, true },
305 
306  /* Coin generation */
307  { "generating", "getgenerate", &getgenerate, true },
308  { "generating", "setgenerate", &setgenerate, true },
309  { "generating", "generate", &generate, true },
310 
311  /* Raw transactions */
312  { "rawtransactions", "createrawtransaction", &createrawtransaction, true },
313  { "rawtransactions", "decoderawtransaction", &decoderawtransaction, true },
314  { "rawtransactions", "decodescript", &decodescript, true },
315  { "rawtransactions", "getrawtransaction", &getrawtransaction, true },
316  { "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
317  { "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
318 #ifdef ENABLE_WALLET
319  { "rawtransactions", "fundrawtransaction", &fundrawtransaction, false },
320 #endif
321 
322  /* Address index */
323  { "addressindex", "getaddressmempool", &getaddressmempool, true },
324  { "addressindex", "getaddressutxos", &getaddressutxos, false },
325  { "addressindex", "getaddressdeltas", &getaddressdeltas, false },
326  { "addressindex", "getaddresstxids", &getaddresstxids, false },
327  { "addressindex", "getaddressbalance", &getaddressbalance, false },
328 
329  /* Utility functions */
330  { "util", "createmultisig", &createmultisig, true },
331  { "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
332  { "util", "verifymessage", &verifymessage, true },
333  { "util", "estimatefee", &estimatefee, true },
334  { "util", "estimatepriority", &estimatepriority, true },
335  { "util", "estimatesmartfee", &estimatesmartfee, true },
336  { "util", "estimatesmartpriority", &estimatesmartpriority, true },
337 
338  /* Not shown in help */
339  { "hidden", "invalidateblock", &invalidateblock, true },
340  { "hidden", "reconsiderblock", &reconsiderblock, true },
341  { "hidden", "setmocktime", &setmocktime, true },
342 #ifdef ENABLE_WALLET
343  { "hidden", "resendwallettransactions", &resendwallettransactions, true},
344 #endif
345 
346  /* Dash features */
347  { "dash", "masternode", &masternode, true },
348  { "dash", "masternodelist", &masternodelist, true },
349  { "dash", "masternodebroadcast", &masternodebroadcast, true },
350  { "dash", "gobject", &gobject, true },
351  { "dash", "getgovernanceinfo", &getgovernanceinfo, true },
352  { "dash", "getsuperblockbudget", &getsuperblockbudget, true },
353  { "dash", "voteraw", &voteraw, true },
354  { "dash", "mnsync", &mnsync, true },
355  { "dash", "spork", &spork, true },
356  { "dash", "getpoolinfo", &getpoolinfo, true },
357  { "dash", "sentinelping", &sentinelping, true },
358 #ifdef ENABLE_WALLET
359  { "dash", "privatesend", &privatesend, false },
360 
361  /* Wallet */
362  { "wallet", "keepass", &keepass, true },
363  { "wallet", "instantsendtoaddress", &instantsendtoaddress, false },
364  { "wallet", "addmultisigaddress", &addmultisigaddress, true },
365  { "wallet", "backupwallet", &backupwallet, true },
366  { "wallet", "dumpprivkey", &dumpprivkey, true },
367  { "wallet", "dumphdinfo", &dumphdinfo, true },
368  { "wallet", "dumpwallet", &dumpwallet, true },
369  { "wallet", "encryptwallet", &encryptwallet, true },
370  { "wallet", "getaccountaddress", &getaccountaddress, true },
371  { "wallet", "getaccount", &getaccount, true },
372  { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
373  { "wallet", "getbalance", &getbalance, false },
374  { "wallet", "getnewaddress", &getnewaddress, true },
375  { "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
376  { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
377  { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false },
378  { "wallet", "gettransaction", &gettransaction, false },
379  { "wallet", "abandontransaction", &abandontransaction, false },
380  { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false },
381  { "wallet", "getwalletinfo", &getwalletinfo, false },
382  { "wallet", "importprivkey", &importprivkey, true },
383  { "wallet", "importwallet", &importwallet, true },
384  { "wallet", "importelectrumwallet", &importelectrumwallet, true },
385  { "wallet", "importaddress", &importaddress, true },
386  { "wallet", "importpubkey", &importpubkey, true },
387  { "wallet", "keypoolrefill", &keypoolrefill, true },
388  { "wallet", "listaccounts", &listaccounts, false },
389  { "wallet", "listaddressgroupings", &listaddressgroupings, false },
390  { "wallet", "listlockunspent", &listlockunspent, false },
391  { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false },
392  { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false },
393  { "wallet", "listsinceblock", &listsinceblock, false },
394  { "wallet", "listtransactions", &listtransactions, false },
395  { "wallet", "listunspent", &listunspent, false },
396  { "wallet", "lockunspent", &lockunspent, true },
397  { "wallet", "move", &movecmd, false },
398  { "wallet", "sendfrom", &sendfrom, false },
399  { "wallet", "sendmany", &sendmany, false },
400  { "wallet", "sendtoaddress", &sendtoaddress, false },
401  { "wallet", "setaccount", &setaccount, true },
402  { "wallet", "settxfee", &settxfee, true },
403  { "wallet", "signmessage", &signmessage, true },
404  { "wallet", "walletlock", &walletlock, true },
405  { "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
406  { "wallet", "walletpassphrase", &walletpassphrase, true },
407 #endif // ENABLE_WALLET
408 };
409 
411 {
412  unsigned int vcidx;
413  for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++)
414  {
415  const CRPCCommand *pcmd;
416 
417  pcmd = &vRPCCommands[vcidx];
418  mapCommands[pcmd->name] = pcmd;
419  }
420 }
421 
422 const CRPCCommand *CRPCTable::operator[](const std::string &name) const
423 {
424  map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
425  if (it == mapCommands.end())
426  return NULL;
427  return (*it).second;
428 }
429 
430 bool StartRPC()
431 {
432  LogPrint("rpc", "Starting RPC\n");
433  fRPCRunning = true;
435  return true;
436 }
437 
439 {
440  LogPrint("rpc", "Interrupting RPC\n");
441  // Interrupt e.g. running longpolls
442  fRPCRunning = false;
443 }
444 
445 void StopRPC()
446 {
447  LogPrint("rpc", "Stopping RPC\n");
448  deadlineTimers.clear();
450 }
451 
453 {
454  return fRPCRunning;
455 }
456 
457 void SetRPCWarmupStatus(const std::string& newStatus)
458 {
460  rpcWarmupStatus = newStatus;
461 }
462 
464 {
466  assert(fRPCInWarmup);
467  fRPCInWarmup = false;
468 }
469 
470 bool RPCIsInWarmup(std::string *outStatus)
471 {
473  if (outStatus)
474  *outStatus = rpcWarmupStatus;
475  return fRPCInWarmup;
476 }
477 
478 void JSONRequest::parse(const UniValue& valRequest)
479 {
480  // Parse request
481  if (!valRequest.isObject())
482  throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
483  const UniValue& request = valRequest.get_obj();
484 
485  // Parse id now so errors from here on will have the id
486  id = find_value(request, "id");
487 
488  // Parse method
489  UniValue valMethod = find_value(request, "method");
490  if (valMethod.isNull())
491  throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
492  if (!valMethod.isStr())
493  throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
494  strMethod = valMethod.get_str();
495  if (strMethod != "getblocktemplate")
496  LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
497 
498  // Parse params
499  UniValue valParams = find_value(request, "params");
500  if (valParams.isArray())
501  params = valParams.get_array();
502  else if (valParams.isNull())
503  params = UniValue(UniValue::VARR);
504  else
505  throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
506 }
507 
508 static UniValue JSONRPCExecOne(const UniValue& req)
509 {
510  UniValue rpc_result(UniValue::VOBJ);
511 
512  JSONRequest jreq;
513  try {
514  jreq.parse(req);
515 
517  rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
518  }
519  catch (const UniValue& objError)
520  {
521  rpc_result = JSONRPCReplyObj(NullUniValue, objError, jreq.id);
522  }
523  catch (const std::exception& e)
524  {
525  rpc_result = JSONRPCReplyObj(NullUniValue,
526  JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
527  }
528 
529  return rpc_result;
530 }
531 
532 std::string JSONRPCExecBatch(const UniValue& vReq)
533 {
535  for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
536  ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
537 
538  return ret.write() + "\n";
539 }
540 
541 UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const
542 {
543  // Return immediately if in warmup
544  {
546  if (fRPCInWarmup)
548  }
549 
550  // Find method
551  const CRPCCommand *pcmd = tableRPC[strMethod];
552  if (!pcmd)
553  throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
554 
555  g_rpcSignals.PreCommand(*pcmd);
556 
557  try
558  {
559  // Execute
560  return pcmd->actor(params, false);
561  }
562  catch (const std::exception& e)
563  {
564  throw JSONRPCError(RPC_MISC_ERROR, e.what());
565  }
566 
567  g_rpcSignals.PostCommand(*pcmd);
568 }
569 
570 std::vector<std::string> CRPCTable::listCommands() const
571 {
572  std::vector<std::string> commandList;
573  typedef std::map<std::string, const CRPCCommand*> commandMap;
574 
575  std::transform( mapCommands.begin(), mapCommands.end(),
576  std::back_inserter(commandList),
577  boost::bind(&commandMap::value_type::first,_1) );
578  return commandList;
579 }
580 
581 std::string HelpExampleCli(const std::string& methodname, const std::string& args)
582 {
583  return "> dash-cli " + methodname + " " + args + "\n";
584 }
585 
586 std::string HelpExampleRpc(const std::string& methodname, const std::string& args)
587 {
588  return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", "
589  "\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/\n";
590 }
591 
593 {
594  timerInterfaces.push_back(iface);
595 }
596 
598 {
599  std::vector<RPCTimerInterface*>::iterator i = std::find(timerInterfaces.begin(), timerInterfaces.end(), iface);
600  assert(i != timerInterfaces.end());
601  timerInterfaces.erase(i);
602 }
603 
604 void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
605 {
606  if (timerInterfaces.empty())
607  throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");
608  deadlineTimers.erase(name);
609  RPCTimerInterface* timerInterface = timerInterfaces.back();
610  LogPrint("rpc", "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name());
611  deadlineTimers.insert(std::make_pair(name, boost::shared_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000))));
612 }
613 
UniValue importprivkey(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:76
UniValue abandontransaction(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1902
UniValue getrawchangeaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:224
UniValue addmultisigaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1151
UniValue gettxoutproof(const UniValue &params, bool fHelp)
UniValue prioritisetransaction(const UniValue &params, bool fHelp)
Definition: mining.cpp:279
vector< unsigned char > ParseHexV(const UniValue &v, string strName)
Definition: server.cpp:147
UniValue getnetworkhashps(const UniValue &params, bool fHelp)
Definition: mining.cpp:81
UniValue listreceivedbyaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1380
UniValue spork(const UniValue &params, bool fHelp)
Definition: misc.cpp:225
UniValue resendwallettransactions(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2505
UniValue walletpassphrase(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2007
const CRPCCommand * operator[](const std::string &name) const
Definition: server.cpp:422
UniValue getaddressbalance(const UniValue &params, bool fHelp)
Definition: misc.cpp:809
UniValue dumpwallet(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:629
UniValue getaddressesbyaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:337
boost::signals2::signal< void()> Started
Definition: server.cpp:44
UniValue getunconfirmedbalance(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:869
enum VType type() const
Definition: univalue.h:155
UniValue getaddresstxids(const UniValue &params, bool fHelp)
Definition: misc.cpp:865
UniValue getgovernanceinfo(const UniValue &params, bool fHelp)
Definition: governance.cpp:897
UniValue importelectrumwallet(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:412
bool IsRPCRunning()
Definition: server.cpp:452
UniValue importpubkey(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:247
UniValue getblockheader(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:336
UniValue keypoolrefill(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1963
UniValue privatesend(const UniValue &params, bool fHelp)
Definition: masternode.cpp:25
void SetRPCWarmupStatus(const std::string &newStatus)
Definition: server.cpp:457
virtual const char * Name()=0
std::string name
Definition: server.h:120
UniValue getdifficulty(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:165
#define strprintf
Definition: tinyformat.h:1011
void OnPreCommand(boost::function< void(const CRPCCommand &)> slot)
Definition: server.cpp:60
std::string JSONRPCExecBatch(const UniValue &vReq)
Definition: server.cpp:532
UniValue id
Definition: server.h:38
static const CAmount COIN
Definition: amount.h:16
UniValue getblocktemplate(const UniValue &params, bool fHelp)
Definition: mining.cpp:337
bool isStr() const
Definition: univalue.h:81
UniValue getaddressdeltas(const UniValue &params, bool fHelp)
Definition: misc.cpp:721
UniValue validateaddress(const UniValue &params, bool fHelp)
Definition: misc.cpp:270
UniValue gobject(const UniValue &params, bool fHelp)
Definition: governance.cpp:25
bool MoneyRange(const CAmount &nValue)
Definition: amount.h:31
void StartShutdown()
Definition: init.cpp:164
uint256 ParseHashO(const UniValue &o, string strKey)
Definition: server.cpp:143
static bool fRPCRunning
Definition: server.cpp:32
UniValue settxfee(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2349
UniValue reconsiderblock(const UniValue &params, bool fHelp)
const std::string & getValStr() const
Definition: univalue.h:66
UniValue getreceivedbyaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:701
virtual RPCTimerBase * NewTimer(boost::function< void(void)> &func, int64_t millis)=0
UniValue dumpprivkey(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:546
void InterruptRPC()
Definition: server.cpp:438
UniValue getbalance(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:792
UniValue clearbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:562
UniValue getspentinfo(const UniValue &params, bool fHelp)
Definition: misc.cpp:948
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: server.cpp:586
UniValue getrawtransaction(const UniValue &params, bool fHelp)
UniValue listaccounts(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1645
UniValue getblockheaders(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:394
UniValue getreceivedbyaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:641
UniValue getsuperblockbudget(const UniValue &params, bool fHelp)
Definition: governance.cpp:955
UniValue sentinelping(const UniValue &params, bool fHelp)
Definition: masternode.cpp:836
bool IsHex(const string &str)
UniValue listtransactions(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1518
UniValue estimatepriority(const UniValue &params, bool fHelp)
Definition: mining.cpp:842
UniValue getaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:305
UniValue gettxout(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:591
UniValue sendmany(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1024
boost::signals2::signal< void(const CRPCCommand &)> PostCommand
Definition: server.cpp:47
static const CRPCCommand vRPCCommands[]
Definition: server.cpp:256
UniValue getblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:483
Transaction already in chain.
Definition: protocol.h:52
UniValue sendfrom(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:958
UniValue backupwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1937
UniValue listunspent(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2533
bool push_back(const UniValue &val)
Definition: univalue.cpp:176
UniValue signmessage(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:585
UniValue getaccountaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:192
UniValue ValueFromAmount(const CAmount &amount)
Definition: server.cpp:122
UniValue sendtoaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:409
Ran out of memory during operation.
Definition: protocol.h:46
UniValue getblockhashes(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:277
UniValue listbanned(const UniValue &params, bool fHelp)
Definition: net.cpp:529
const UniValue & find_value(const UniValue &obj, const std::string &name)
Definition: univalue.cpp:280
UniValue getaddressutxos(const UniValue &params, bool fHelp)
Definition: misc.cpp:654
UniValue fundrawtransaction(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2651
UniValue submitblock(const UniValue &params, bool fHelp)
Definition: mining.cpp:755
int64_t CAmount
Definition: amount.h:14
void SetRPCWarmupFinished()
Definition: server.cpp:463
UniValue getaddednodeinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:257
UniValue disconnectnode(const UniValue &params, bool fHelp)
Definition: net.cpp:234
UniValue verifychain(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:671
boost::signals2::signal< void(const CRPCCommand &)> PreCommand
Definition: server.cpp:46
const char * uvTypeName(UniValue::VType t)
Definition: univalue.cpp:265
const CRPCTable tableRPC
Definition: server.cpp:614
UniValue getnewaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:113
UniValue setban(const UniValue &params, bool fHelp)
Definition: net.cpp:465
const UniValue & get_obj() const
Definition: univalue.cpp:347
UniValue setaccount(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:259
UniValue getmempoolinfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:961
void RPCRunLater(const std::string &name, boost::function< void(void)> func, int64_t nSeconds)
Definition: server.cpp:604
static int LogPrint(const char *category, const char *format)
Definition: util.h:126
UniValue getblockhash(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:311
static std::vector< RPCTimerInterface * > timerInterfaces
Definition: server.cpp:37
UniValue keepass(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2455
#define LOCK(cs)
Definition: sync.h:168
UniValue getblockcount(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:131
const char * name
Definition: rest.cpp:37
rpcfn_type actor
Definition: server.h:121
void OnStarted(boost::function< void()> slot)
Definition: server.cpp:50
UniValue masternode(const UniValue &params, bool fHelp)
Definition: masternode.cpp:96
UniValue getwalletinfo(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2376
UniValue listlockunspent(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2300
static UniValue JSONRPCExecOne(const UniValue &req)
Definition: server.cpp:508
UniValue setgenerate(const UniValue &params, bool fHelp)
Definition: mining.cpp:191
bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out)
UniValue signrawtransaction(const UniValue &params, bool fHelp)
UniValue createrawtransaction(const UniValue &params, bool fHelp)
bool isNull() const
Definition: univalue.h:77
Server is in safe mode, and command is not allowed in safe mode.
Definition: protocol.h:43
UniValue listsinceblock(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1726
UniValue getconnectioncount(const UniValue &params, bool fHelp)
Definition: net.cpp:28
UniValue decoderawtransaction(const UniValue &params, bool fHelp)
vector< unsigned char > ParseHex(const char *psz)
bool isArray() const
Definition: univalue.h:83
UniValue createmultisig(const UniValue &params, bool fHelp)
Definition: misc.cpp:401
UniValue encryptwallet(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2159
General application defined errors.
Definition: protocol.h:41
UniValue getinfo(const UniValue &params, bool fHelp)
Definition: misc.cpp:47
UniValue walletpassphrasechange(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2074
UniValue listaddressgroupings(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:534
UniValue importaddress(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:181
UniValue lockunspent(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2216
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: server.cpp:581
CAmount AmountFromValue(const UniValue &value)
Definition: server.cpp:110
UniValue voteraw(const UniValue &params, bool fHelp)
Definition: governance.cpp:836
UniValue getnettotals(const UniValue &params, bool fHelp)
Definition: net.cpp:326
uint256 ParseHashV(const UniValue &v, string strName)
Definition: server.cpp:132
static struct CRPCSignals g_rpcSignals
UniValue dumphdinfo(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:583
UniValue masternodebroadcast(const UniValue &params, bool fHelp)
Definition: masternode.cpp:607
void RPCTypeCheckObj(const UniValue &o, const map< string, UniValue::VType > &typesExpected, bool fAllowNull)
Definition: server.cpp:91
UniValue(* rpcfn_type)(const UniValue &params, bool fHelp)
Definition: server.h:114
UniValue instantsendtoaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:476
UniValue importwallet(const UniValue &params, bool fHelp)
Definition: rpcdump.cpp:305
UniValue generate(const UniValue &params, bool fHelp)
Definition: mining.cpp:122
UniValue masternodelist(const UniValue &params, bool fHelp)
Definition: masternode.cpp:454
UniValue sendrawtransaction(const UniValue &params, bool fHelp)
void RPCTypeCheck(const UniValue &params, const list< UniValue::VType > &typesExpected, bool fAllowNull)
Definition: server.cpp:70
void RPCRegisterTimerInterface(RPCTimerInterface *iface)
Definition: server.cpp:592
void StopRPC()
Definition: server.cpp:445
UniValue getaddressmempool(const UniValue &params, bool fHelp)
Definition: misc.cpp:583
std::string category
Definition: server.h:119
UniValue gettxoutsetinfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:553
UniValue getrawmempool(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:234
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
UniValue movecmd(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:885
bool isNum() const
Definition: univalue.h:82
UniValue setnetworkactive(const UniValue &params, bool fHelp)
Definition: net.cpp:580
UniValue ping(const UniValue &params, bool fHelp)
Definition: net.cpp:47
UniValue getbestblockhash(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:148
UniValue invalidateblock(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:983
bool RPCIsInWarmup(std::string *outStatus)
Definition: server.cpp:470
const UniValue NullUniValue
Definition: univalue.cpp:78
UniValue getpeerinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:70
UniValue getnetworkinfo(const UniValue &params, bool fHelp)
Definition: net.cpp:392
UniValue mnsync(const UniValue &params, bool fHelp)
Definition: misc.cpp:143
void parse(const UniValue &valRequest)
Definition: server.cpp:478
Standard JSON-RPC 2.0 errors.
Definition: protocol.h:34
std::string help(const std::string &name) const
Definition: server.cpp:165
UniValue verifytxoutproof(const UniValue &params, bool fHelp)
vector< unsigned char > ParseHexO(const UniValue &o, string strKey)
Definition: server.cpp:156
UniValue verifymessage(const UniValue &params, bool fHelp)
Definition: misc.cpp:444
bool StartRPC()
Definition: server.cpp:430
UniValue listreceivedbyaddress(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1339
boost::signals2::signal< void()> Stopped
Definition: server.cpp:45
UniValue estimatesmartfee(const UniValue &params, bool fHelp)
Definition: mining.cpp:869
CRPCTable()
Definition: server.cpp:410
UniValue stop(const UniValue &params, bool fHelp)
Definition: server.cpp:240
static std::string rpcWarmupStatus("RPC server started")
void OnStopped(boost::function< void()> slot)
Definition: server.cpp:55
bool isObject() const
Definition: univalue.h:84
UniValue setmocktime(const UniValue &params, bool fHelp)
Definition: misc.cpp:498
UniValue addnode(const UniValue &params, bool fHelp)
Definition: net.cpp:189
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: protocol.cpp:39
UniValue params
Definition: server.h:40
UniValue getpoolinfo(const UniValue &params, bool fHelp)
Definition: masternode.cpp:65
static CCriticalSection cs_rpcWarmup
Definition: server.cpp:35
UniValue estimatefee(const UniValue &params, bool fHelp)
Definition: mining.cpp:811
UniValue execute(const std::string &method, const UniValue &params) const
Definition: server.cpp:541
std::string strMethod
Definition: server.h:39
UniValue debug(const UniValue &params, bool fHelp)
Definition: misc.cpp:119
void OnPostCommand(boost::function< void(const CRPCCommand &)> slot)
Definition: server.cpp:65
#define PAIRTYPE(t1, t2)
std::vector< std::string > listCommands() const
Definition: server.cpp:570
UniValue estimatesmartpriority(const UniValue &params, bool fHelp)
Definition: mining.cpp:905
UniValue decodescript(const UniValue &params, bool fHelp)
UniValue JSONRPCError(int code, const string &message)
Definition: protocol.cpp:57
UniValue gettransaction(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:1821
static std::map< std::string, boost::shared_ptr< RPCTimerBase > > deadlineTimers
Definition: server.cpp:40
size_t size() const
Definition: univalue.h:69
UniValue getchaintips(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:837
UniValue getblockchaininfo(const UniValue &params, bool fHelp)
Definition: blockchain.cpp:743
string SanitizeString(const string &str, int rule)
const UniValue & get_array() const
Definition: univalue.cpp:354
std::string get_str() const
Definition: univalue.cpp:310
static bool fRPCInWarmup
Definition: server.cpp:33
UniValue help(const UniValue &params, bool fHelp)
Definition: server.cpp:220
UniValue getmininginfo(const UniValue &params, bool fHelp)
Definition: mining.cpp:235
UniValue walletlock(const UniValue &params, bool fHelp)
Definition: rpcwallet.cpp:2120
result
Definition: rpcuser.py:37
void RPCUnregisterTimerInterface(RPCTimerInterface *iface)
Definition: server.cpp:597
UniValue getgenerate(const UniValue &params, bool fHelp)
Definition: mining.cpp:103