Dash Core  0.12.2.1
P2P Digital Currency
misc.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 "base58.h"
8 #include "clientversion.h"
9 #include "init.h"
10 #include "validation.h"
11 #include "net.h"
12 #include "netbase.h"
13 #include "rpc/server.h"
14 #include "timedata.h"
15 #include "txmempool.h"
16 #include "util.h"
17 #include "spork.h"
18 #include "utilstrencodings.h"
19 #ifdef ENABLE_WALLET
20 #include "masternode-sync.h"
21 #include "wallet/wallet.h"
22 #include "wallet/walletdb.h"
23 #endif
24 
25 #include <stdint.h>
26 
27 #include <boost/assign/list_of.hpp>
28 #include <boost/algorithm/string.hpp>
29 
30 #include <univalue.h>
31 
32 using namespace std;
33 
47 UniValue getinfo(const UniValue& params, bool fHelp)
48 {
49  if (fHelp || params.size() != 0)
50  throw runtime_error(
51  "getinfo\n"
52  "Returns an object containing various state info.\n"
53  "\nResult:\n"
54  "{\n"
55  " \"version\": xxxxx, (numeric) the server version\n"
56  " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
57  " \"walletversion\": xxxxx, (numeric) the wallet version\n"
58  " \"balance\": xxxxxxx, (numeric) the total dash balance of the wallet\n"
59  " \"privatesend_balance\": xxxxxx, (numeric) the anonymized dash balance of the wallet\n"
60  " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
61  " \"timeoffset\": xxxxx, (numeric) the time offset\n"
62  " \"connections\": xxxxx, (numeric) the number of connections\n"
63  " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
64  " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
65  " \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
66  " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
67  " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
68  " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
69  " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
70  " \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
71  " \"errors\": \"...\" (string) any error messages\n"
72  "}\n"
73  "\nExamples:\n"
74  + HelpExampleCli("getinfo", "")
75  + HelpExampleRpc("getinfo", "")
76  );
77 
78 #ifdef ENABLE_WALLET
80 #else
81  LOCK(cs_main);
82 #endif
83 
84  proxyType proxy;
85  GetProxy(NET_IPV4, proxy);
86 
88  obj.push_back(Pair("version", CLIENT_VERSION));
89  obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
90 #ifdef ENABLE_WALLET
91  if (pwalletMain) {
92  obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
94  if(!fLiteMode)
95  obj.push_back(Pair("privatesend_balance", ValueFromAmount(pwalletMain->GetAnonymizedBalance())));
96  }
97 #endif
98  obj.push_back(Pair("blocks", (int)chainActive.Height()));
99  obj.push_back(Pair("timeoffset", GetTimeOffset()));
100  if(g_connman)
101  obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));
102  obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
103  obj.push_back(Pair("difficulty", (double)GetDifficulty()));
104  obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
105 #ifdef ENABLE_WALLET
106  if (pwalletMain) {
107  obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
108  obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
109  }
111  obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
112  obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
113 #endif
114  obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
115  obj.push_back(Pair("errors", GetWarnings("statusbar")));
116  return obj;
117 }
118 
119 UniValue debug(const UniValue& params, bool fHelp)
120 {
121  if (fHelp || params.size() != 1)
122  throw runtime_error(
123  "debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool"
124  "|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|"
125  "dash|privatesend|instantsend|masternode|spork|keepass|mnpayments|gobject )\n"
126  "Change debug category on the fly. Specify single category or use comma to specify many.\n"
127  "\nExamples:\n"
128  + HelpExampleCli("debug", "dash")
129  + HelpExampleRpc("debug", "dash,net")
130  );
131 
132  std::string strMode = params[0].get_str();
133 
134  mapMultiArgs["-debug"].clear();
135  boost::split(mapMultiArgs["-debug"], strMode, boost::is_any_of(","));
136  mapArgs["-debug"] = mapMultiArgs["-debug"][mapMultiArgs["-debug"].size() - 1];
137 
138  fDebug = mapArgs["-debug"] != "0";
139 
140  return "Debug mode: " + (fDebug ? strMode : "off");
141 }
142 
143 UniValue mnsync(const UniValue& params, bool fHelp)
144 {
145  if (fHelp || params.size() != 1)
146  throw runtime_error(
147  "mnsync [status|next|reset]\n"
148  "Returns the sync status, updates to the next step or resets it entirely.\n"
149  );
150 
151  std::string strMode = params[0].get_str();
152 
153  if(strMode == "status") {
154  UniValue objStatus(UniValue::VOBJ);
155  objStatus.push_back(Pair("AssetID", masternodeSync.GetAssetID()));
156  objStatus.push_back(Pair("AssetName", masternodeSync.GetAssetName()));
157  objStatus.push_back(Pair("AssetStartTime", masternodeSync.GetAssetStartTime()));
158  objStatus.push_back(Pair("Attempt", masternodeSync.GetAttempt()));
159  objStatus.push_back(Pair("IsBlockchainSynced", masternodeSync.IsBlockchainSynced()));
160  objStatus.push_back(Pair("IsMasternodeListSynced", masternodeSync.IsMasternodeListSynced()));
161  objStatus.push_back(Pair("IsWinnersListSynced", masternodeSync.IsWinnersListSynced()));
162  objStatus.push_back(Pair("IsSynced", masternodeSync.IsSynced()));
163  objStatus.push_back(Pair("IsFailed", masternodeSync.IsFailed()));
164  return objStatus;
165  }
166 
167  if(strMode == "next")
168  {
170  return "sync updated to " + masternodeSync.GetAssetName();
171  }
172 
173  if(strMode == "reset")
174  {
177  return "success";
178  }
179  return "failure";
180 }
181 
182 #ifdef ENABLE_WALLET
183 class DescribeAddressVisitor : public boost::static_visitor<UniValue>
184 {
185 public:
186  UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
187 
188  UniValue operator()(const CKeyID &keyID) const {
190  CPubKey vchPubKey;
191  obj.push_back(Pair("isscript", false));
192  if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
193  obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
194  obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
195  }
196  return obj;
197  }
198 
199  UniValue operator()(const CScriptID &scriptID) const {
201  CScript subscript;
202  obj.push_back(Pair("isscript", true));
203  if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) {
204  std::vector<CTxDestination> addresses;
205  txnouttype whichType;
206  int nRequired;
207  ExtractDestinations(subscript, whichType, addresses, nRequired);
208  obj.push_back(Pair("script", GetTxnOutputType(whichType)));
209  obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
211  BOOST_FOREACH(const CTxDestination& addr, addresses)
212  a.push_back(CBitcoinAddress(addr).ToString());
213  obj.push_back(Pair("addresses", a));
214  if (whichType == TX_MULTISIG)
215  obj.push_back(Pair("sigsrequired", nRequired));
216  }
217  return obj;
218  }
219 };
220 #endif
221 
222 /*
223  Used for updating/reading spork settings on the network
224 */
225 UniValue spork(const UniValue& params, bool fHelp)
226 {
227  if(params.size() == 1 && params[0].get_str() == "show"){
229  for(int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++){
230  if(sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
232  }
233  return ret;
234  } else if(params.size() == 1 && params[0].get_str() == "active"){
236  for(int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++){
237  if(sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
239  }
240  return ret;
241  } else if (params.size() == 2){
242  int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str());
243  if(nSporkID == -1){
244  return "Invalid spork name";
245  }
246 
247  if (!g_connman)
248  throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
249 
250  // SPORK VALUE
251  int64_t nValue = params[1].get_int64();
252 
253  //broadcast new spork
254  if(sporkManager.UpdateSpork(nSporkID, nValue, *g_connman)){
255  sporkManager.ExecuteSpork(nSporkID, nValue);
256  return "success";
257  } else {
258  return "failure";
259  }
260 
261  }
262 
263  throw runtime_error(
264  "spork <name> [<value>]\n"
265  "<name> is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active"
266  "<value> is a epoch datetime to enable or disable spork"
268 }
269 
270 UniValue validateaddress(const UniValue& params, bool fHelp)
271 {
272  if (fHelp || params.size() != 1)
273  throw runtime_error(
274  "validateaddress \"dashaddress\"\n"
275  "\nReturn information about the given dash address.\n"
276  "\nArguments:\n"
277  "1. \"dashaddress\" (string, required) The dash address to validate\n"
278  "\nResult:\n"
279  "{\n"
280  " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
281  " \"address\" : \"dashaddress\", (string) The dash address validated\n"
282  " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n"
283  " \"ismine\" : true|false, (boolean) If the address is yours or not\n"
284  " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n"
285  " \"isscript\" : true|false, (boolean) If the key is a script\n"
286  " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n"
287  " \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
288  " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n"
289  " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n"
290  " \"hdchainid\" : \"<hash>\" (string, optional) The ID of the HD chain\n"
291  "}\n"
292  "\nExamples:\n"
293  + HelpExampleCli("validateaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"")
294  + HelpExampleRpc("validateaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"")
295  );
296 
297 #ifdef ENABLE_WALLET
299 #else
300  LOCK(cs_main);
301 #endif
302 
303  CBitcoinAddress address(params[0].get_str());
304  bool isValid = address.IsValid();
305 
307  ret.push_back(Pair("isvalid", isValid));
308  if (isValid)
309  {
310  CTxDestination dest = address.Get();
311  string currentAddress = address.ToString();
312  ret.push_back(Pair("address", currentAddress));
313 
314  CScript scriptPubKey = GetScriptForDestination(dest);
315  ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
316 
317 #ifdef ENABLE_WALLET
319  ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
320  ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
321  UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
322  ret.pushKVs(detail);
323  if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
324  ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
325  CKeyID keyID;
326  CHDChain hdChainCurrent;
327  if (pwalletMain && address.GetKeyID(keyID) && pwalletMain->mapHdPubKeys.count(keyID) && pwalletMain->GetHDChain(hdChainCurrent))
328  {
329  ret.push_back(Pair("hdkeypath", pwalletMain->mapHdPubKeys[keyID].GetKeyPath()));
330  ret.push_back(Pair("hdchainid", hdChainCurrent.GetID().GetHex()));
331  }
332 #endif
333  }
334  return ret;
335 }
336 
341 {
342  int nRequired = params[0].get_int();
343  const UniValue& keys = params[1].get_array();
344 
345  // Gather public keys
346  if (nRequired < 1)
347  throw runtime_error("a multisignature address must require at least one key to redeem");
348  if ((int)keys.size() < nRequired)
349  throw runtime_error(
350  strprintf("not enough keys supplied "
351  "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
352  if (keys.size() > 16)
353  throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
354  std::vector<CPubKey> pubkeys;
355  pubkeys.resize(keys.size());
356  for (unsigned int i = 0; i < keys.size(); i++)
357  {
358  const std::string& ks = keys[i].get_str();
359 #ifdef ENABLE_WALLET
360  // Case 1: Dash address and we have full public key:
361  CBitcoinAddress address(ks);
362  if (pwalletMain && address.IsValid())
363  {
364  CKeyID keyID;
365  if (!address.GetKeyID(keyID))
366  throw runtime_error(
367  strprintf("%s does not refer to a key",ks));
368  CPubKey vchPubKey;
369  if (!pwalletMain->GetPubKey(keyID, vchPubKey))
370  throw runtime_error(
371  strprintf("no full public key for address %s",ks));
372  if (!vchPubKey.IsFullyValid())
373  throw runtime_error(" Invalid public key: "+ks);
374  pubkeys[i] = vchPubKey;
375  }
376 
377  // Case 2: hex public key
378  else
379 #endif
380  if (IsHex(ks))
381  {
382  CPubKey vchPubKey(ParseHex(ks));
383  if (!vchPubKey.IsFullyValid())
384  throw runtime_error(" Invalid public key: "+ks);
385  pubkeys[i] = vchPubKey;
386  }
387  else
388  {
389  throw runtime_error(" Invalid public key: "+ks);
390  }
391  }
392  CScript result = GetScriptForMultisig(nRequired, pubkeys);
393 
394  if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
395  throw runtime_error(
396  strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE));
397 
398  return result;
399 }
400 
401 UniValue createmultisig(const UniValue& params, bool fHelp)
402 {
403  if (fHelp || params.size() < 2 || params.size() > 2)
404  {
405  string msg = "createmultisig nrequired [\"key\",...]\n"
406  "\nCreates a multi-signature address with n signature of m keys required.\n"
407  "It returns a json object with the address and redeemScript.\n"
408 
409  "\nArguments:\n"
410  "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
411  "2. \"keys\" (string, required) A json array of keys which are dash addresses or hex-encoded public keys\n"
412  " [\n"
413  " \"key\" (string) dash address or hex-encoded public key\n"
414  " ,...\n"
415  " ]\n"
416 
417  "\nResult:\n"
418  "{\n"
419  " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
420  " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
421  "}\n"
422 
423  "\nExamples:\n"
424  "\nCreate a multisig address from 2 addresses\n"
425  + HelpExampleCli("createmultisig", "2 \"[\\\"Xt4qk9uKvQYAonVGSZNXqxeDmtjaEWgfrs\\\",\\\"XoSoWQkpgLpppPoyyzbUFh1fq2RBvW6UK1\\\"]\"") +
426  "\nAs a json rpc call\n"
427  + HelpExampleRpc("createmultisig", "2, \"[\\\"Xt4qk9uKvQYAonVGSZNXqxeDmtjaEWgfrs\\\",\\\"XoSoWQkpgLpppPoyyzbUFh1fq2RBvW6UK1\\\"]\"")
428  ;
429  throw runtime_error(msg);
430  }
431 
432  // Construct using pay-to-script-hash:
433  CScript inner = _createmultisig_redeemScript(params);
434  CScriptID innerID(inner);
435  CBitcoinAddress address(innerID);
436 
438  result.push_back(Pair("address", address.ToString()));
439  result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
440 
441  return result;
442 }
443 
444 UniValue verifymessage(const UniValue& params, bool fHelp)
445 {
446  if (fHelp || params.size() != 3)
447  throw runtime_error(
448  "verifymessage \"dashaddress\" \"signature\" \"message\"\n"
449  "\nVerify a signed message\n"
450  "\nArguments:\n"
451  "1. \"dashaddress\" (string, required) The dash address to use for the signature.\n"
452  "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
453  "3. \"message\" (string, required) The message that was signed.\n"
454  "\nResult:\n"
455  "true|false (boolean) If the signature is verified or not.\n"
456  "\nExamples:\n"
457  "\nUnlock the wallet for 30 seconds\n"
458  + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
459  "\nCreate the signature\n"
460  + HelpExampleCli("signmessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\" \"my message\"") +
461  "\nVerify the signature\n"
462  + HelpExampleCli("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\" \"signature\" \"my message\"") +
463  "\nAs json rpc\n"
464  + HelpExampleRpc("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\", \"signature\", \"my message\"")
465  );
466 
467  LOCK(cs_main);
468 
469  string strAddress = params[0].get_str();
470  string strSign = params[1].get_str();
471  string strMessage = params[2].get_str();
472 
473  CBitcoinAddress addr(strAddress);
474  if (!addr.IsValid())
475  throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
476 
477  CKeyID keyID;
478  if (!addr.GetKeyID(keyID))
479  throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
480 
481  bool fInvalid = false;
482  vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
483 
484  if (fInvalid)
485  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
486 
487  CHashWriter ss(SER_GETHASH, 0);
488  ss << strMessageMagic;
489  ss << strMessage;
490 
491  CPubKey pubkey;
492  if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
493  return false;
494 
495  return (pubkey.GetID() == keyID);
496 }
497 
498 UniValue setmocktime(const UniValue& params, bool fHelp)
499 {
500  if (fHelp || params.size() != 1)
501  throw runtime_error(
502  "setmocktime timestamp\n"
503  "\nSet the local time to given timestamp (-regtest only)\n"
504  "\nArguments:\n"
505  "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n"
506  " Pass 0 to go back to using the system time."
507  );
508 
509  if (!Params().MineBlocksOnDemand())
510  throw runtime_error("setmocktime for regression testing (-regtest mode) only");
511 
512  // For now, don't change mocktime if we're in the middle of validation, as
513  // this could have an effect on mempool time-based eviction, as well as
514  // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
515  // TODO: figure out the right way to synchronize around mocktime, and
516  // ensure all callsites of GetTime() are accessing this safely.
517  LOCK(cs_main);
518 
519  RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
520  SetMockTime(params[0].get_int64());
521 
522  return NullUniValue;
523 }
524 
525 bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address)
526 {
527  if (type == 2) {
528  address = CBitcoinAddress(CScriptID(hash)).ToString();
529  } else if (type == 1) {
530  address = CBitcoinAddress(CKeyID(hash)).ToString();
531  } else {
532  return false;
533  }
534  return true;
535 }
536 
537 bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint160, int> > &addresses)
538 {
539  if (params[0].isStr()) {
540  CBitcoinAddress address(params[0].get_str());
541  uint160 hashBytes;
542  int type = 0;
543  if (!address.GetIndexKey(hashBytes, type)) {
544  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
545  }
546  addresses.push_back(std::make_pair(hashBytes, type));
547  } else if (params[0].isObject()) {
548 
549  UniValue addressValues = find_value(params[0].get_obj(), "addresses");
550  if (!addressValues.isArray()) {
551  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array");
552  }
553 
554  std::vector<UniValue> values = addressValues.getValues();
555 
556  for (std::vector<UniValue>::iterator it = values.begin(); it != values.end(); ++it) {
557 
558  CBitcoinAddress address(it->get_str());
559  uint160 hashBytes;
560  int type = 0;
561  if (!address.GetIndexKey(hashBytes, type)) {
562  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
563  }
564  addresses.push_back(std::make_pair(hashBytes, type));
565  }
566  } else {
567  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
568  }
569 
570  return true;
571 }
572 
573 bool heightSort(std::pair<CAddressUnspentKey, CAddressUnspentValue> a,
574  std::pair<CAddressUnspentKey, CAddressUnspentValue> b) {
575  return a.second.blockHeight < b.second.blockHeight;
576 }
577 
578 bool timestampSort(std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> a,
579  std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> b) {
580  return a.second.time < b.second.time;
581 }
582 
583 UniValue getaddressmempool(const UniValue& params, bool fHelp)
584 {
585  if (fHelp || params.size() != 1)
586  throw runtime_error(
587  "getaddressmempool\n"
588  "\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n"
589  "\nArguments:\n"
590  "{\n"
591  " \"addresses\"\n"
592  " [\n"
593  " \"address\" (string) The base58check encoded address\n"
594  " ,...\n"
595  " ]\n"
596  "}\n"
597  "\nResult:\n"
598  "[\n"
599  " {\n"
600  " \"address\" (string) The base58check encoded address\n"
601  " \"txid\" (string) The related txid\n"
602  " \"index\" (number) The related input or output index\n"
603  " \"satoshis\" (number) The difference of duffs\n"
604  " \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n"
605  " \"prevtxid\" (string) The previous txid (if spending)\n"
606  " \"prevout\" (string) The previous transaction output index (if spending)\n"
607  " }\n"
608  "]\n"
609  "\nExamples:\n"
610  + HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
611  + HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
612  );
613 
614  std::vector<std::pair<uint160, int> > addresses;
615 
616  if (!getAddressesFromParams(params, addresses)) {
617  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
618  }
619 
620  std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > indexes;
621 
622  if (!mempool.getAddressIndex(addresses, indexes)) {
623  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
624  }
625 
626  std::sort(indexes.begin(), indexes.end(), timestampSort);
627 
629 
630  for (std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> >::iterator it = indexes.begin();
631  it != indexes.end(); it++) {
632 
633  std::string address;
634  if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) {
635  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
636  }
637 
638  UniValue delta(UniValue::VOBJ);
639  delta.push_back(Pair("address", address));
640  delta.push_back(Pair("txid", it->first.txhash.GetHex()));
641  delta.push_back(Pair("index", (int)it->first.index));
642  delta.push_back(Pair("satoshis", it->second.amount));
643  delta.push_back(Pair("timestamp", it->second.time));
644  if (it->second.amount < 0) {
645  delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex()));
646  delta.push_back(Pair("prevout", (int)it->second.prevout));
647  }
648  result.push_back(delta);
649  }
650 
651  return result;
652 }
653 
654 UniValue getaddressutxos(const UniValue& params, bool fHelp)
655 {
656  if (fHelp || params.size() != 1)
657  throw runtime_error(
658  "getaddressutxos\n"
659  "\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n"
660  "\nArguments:\n"
661  "{\n"
662  " \"addresses\"\n"
663  " [\n"
664  " \"address\" (string) The base58check encoded address\n"
665  " ,...\n"
666  " ]\n"
667  "}\n"
668  "\nResult\n"
669  "[\n"
670  " {\n"
671  " \"address\" (string) The address base58check encoded\n"
672  " \"txid\" (string) The output txid\n"
673  " \"outputIndex\" (number) The output index\n"
674  " \"script\" (string) The script hex encoded\n"
675  " \"satoshis\" (number) The number of duffs of the output\n"
676  " \"height\" (number) The block height\n"
677  " }\n"
678  "]\n"
679  "\nExamples:\n"
680  + HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
681  + HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
682  );
683 
684  std::vector<std::pair<uint160, int> > addresses;
685 
686  if (!getAddressesFromParams(params, addresses)) {
687  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
688  }
689 
690  std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
691 
692  for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
693  if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) {
694  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
695  }
696  }
697 
698  std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort);
699 
701 
702  for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) {
703  UniValue output(UniValue::VOBJ);
704  std::string address;
705  if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) {
706  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
707  }
708 
709  output.push_back(Pair("address", address));
710  output.push_back(Pair("txid", it->first.txhash.GetHex()));
711  output.push_back(Pair("outputIndex", (int)it->first.index));
712  output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end())));
713  output.push_back(Pair("satoshis", it->second.satoshis));
714  output.push_back(Pair("height", it->second.blockHeight));
715  result.push_back(output);
716  }
717 
718  return result;
719 }
720 
721 UniValue getaddressdeltas(const UniValue& params, bool fHelp)
722 {
723  if (fHelp || params.size() != 1 || !params[0].isObject())
724  throw runtime_error(
725  "getaddressdeltas\n"
726  "\nReturns all changes for an address (requires addressindex to be enabled).\n"
727  "\nArguments:\n"
728  "{\n"
729  " \"addresses\"\n"
730  " [\n"
731  " \"address\" (string) The base58check encoded address\n"
732  " ,...\n"
733  " ]\n"
734  " \"start\" (number) The start block height\n"
735  " \"end\" (number) The end block height\n"
736  "}\n"
737  "\nResult:\n"
738  "[\n"
739  " {\n"
740  " \"satoshis\" (number) The difference of duffs\n"
741  " \"txid\" (string) The related txid\n"
742  " \"index\" (number) The related input or output index\n"
743  " \"blockindex\" (number) The related block index\n"
744  " \"height\" (number) The block height\n"
745  " \"address\" (string) The base58check encoded address\n"
746  " }\n"
747  "]\n"
748  "\nExamples:\n"
749  + HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
750  + HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
751  );
752 
753 
754  UniValue startValue = find_value(params[0].get_obj(), "start");
755  UniValue endValue = find_value(params[0].get_obj(), "end");
756 
757  int start = 0;
758  int end = 0;
759 
760  if (startValue.isNum() && endValue.isNum()) {
761  start = startValue.get_int();
762  end = endValue.get_int();
763  if (end < start) {
764  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start");
765  }
766  }
767 
768  std::vector<std::pair<uint160, int> > addresses;
769 
770  if (!getAddressesFromParams(params, addresses)) {
771  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
772  }
773 
774  std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
775 
776  for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
777  if (start > 0 && end > 0) {
778  if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) {
779  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
780  }
781  } else {
782  if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
783  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
784  }
785  }
786  }
787 
789 
790  for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
791  std::string address;
792  if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) {
793  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
794  }
795 
796  UniValue delta(UniValue::VOBJ);
797  delta.push_back(Pair("satoshis", it->second));
798  delta.push_back(Pair("txid", it->first.txhash.GetHex()));
799  delta.push_back(Pair("index", (int)it->first.index));
800  delta.push_back(Pair("blockindex", (int)it->first.txindex));
801  delta.push_back(Pair("height", it->first.blockHeight));
802  delta.push_back(Pair("address", address));
803  result.push_back(delta);
804  }
805 
806  return result;
807 }
808 
809 UniValue getaddressbalance(const UniValue& params, bool fHelp)
810 {
811  if (fHelp || params.size() != 1)
812  throw runtime_error(
813  "getaddressbalance\n"
814  "\nReturns the balance for an address(es) (requires addressindex to be enabled).\n"
815  "\nArguments:\n"
816  "{\n"
817  " \"addresses\"\n"
818  " [\n"
819  " \"address\" (string) The base58check encoded address\n"
820  " ,...\n"
821  " ]\n"
822  "}\n"
823  "\nResult:\n"
824  "{\n"
825  " \"balance\" (string) The current balance in duffs\n"
826  " \"received\" (string) The total number of duffs received (including change)\n"
827  "}\n"
828  "\nExamples:\n"
829  + HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
830  + HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
831  );
832 
833  std::vector<std::pair<uint160, int> > addresses;
834 
835  if (!getAddressesFromParams(params, addresses)) {
836  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
837  }
838 
839  std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
840 
841  for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
842  if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
843  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
844  }
845  }
846 
847  CAmount balance = 0;
848  CAmount received = 0;
849 
850  for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
851  if (it->second > 0) {
852  received += it->second;
853  }
854  balance += it->second;
855  }
856 
858  result.push_back(Pair("balance", balance));
859  result.push_back(Pair("received", received));
860 
861  return result;
862 
863 }
864 
865 UniValue getaddresstxids(const UniValue& params, bool fHelp)
866 {
867  if (fHelp || params.size() != 1)
868  throw runtime_error(
869  "getaddresstxids\n"
870  "\nReturns the txids for an address(es) (requires addressindex to be enabled).\n"
871  "\nArguments:\n"
872  "{\n"
873  " \"addresses\"\n"
874  " [\n"
875  " \"address\" (string) The base58check encoded address\n"
876  " ,...\n"
877  " ]\n"
878  " \"start\" (number) The start block height\n"
879  " \"end\" (number) The end block height\n"
880  "}\n"
881  "\nResult:\n"
882  "[\n"
883  " \"transactionid\" (string) The transaction id\n"
884  " ,...\n"
885  "]\n"
886  "\nExamples:\n"
887  + HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
888  + HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
889  );
890 
891  std::vector<std::pair<uint160, int> > addresses;
892 
893  if (!getAddressesFromParams(params, addresses)) {
894  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
895  }
896 
897  int start = 0;
898  int end = 0;
899  if (params[0].isObject()) {
900  UniValue startValue = find_value(params[0].get_obj(), "start");
901  UniValue endValue = find_value(params[0].get_obj(), "end");
902  if (startValue.isNum() && endValue.isNum()) {
903  start = startValue.get_int();
904  end = endValue.get_int();
905  }
906  }
907 
908  std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
909 
910  for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
911  if (start > 0 && end > 0) {
912  if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) {
913  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
914  }
915  } else {
916  if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
917  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
918  }
919  }
920  }
921 
922  std::set<std::pair<int, std::string> > txids;
924 
925  for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
926  int height = it->first.blockHeight;
927  std::string txid = it->first.txhash.GetHex();
928 
929  if (addresses.size() > 1) {
930  txids.insert(std::make_pair(height, txid));
931  } else {
932  if (txids.insert(std::make_pair(height, txid)).second) {
933  result.push_back(txid);
934  }
935  }
936  }
937 
938  if (addresses.size() > 1) {
939  for (std::set<std::pair<int, std::string> >::const_iterator it=txids.begin(); it!=txids.end(); it++) {
940  result.push_back(it->second);
941  }
942  }
943 
944  return result;
945 
946 }
947 
948 UniValue getspentinfo(const UniValue& params, bool fHelp)
949 {
950 
951  if (fHelp || params.size() != 1 || !params[0].isObject())
952  throw runtime_error(
953  "getspentinfo\n"
954  "\nReturns the txid and index where an output is spent.\n"
955  "\nArguments:\n"
956  "{\n"
957  " \"txid\" (string) The hex string of the txid\n"
958  " \"index\" (number) The start block height\n"
959  "}\n"
960  "\nResult:\n"
961  "{\n"
962  " \"txid\" (string) The transaction id\n"
963  " \"index\" (number) The spending input index\n"
964  " ,...\n"
965  "}\n"
966  "\nExamples:\n"
967  + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'")
968  + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}")
969  );
970 
971  UniValue txidValue = find_value(params[0].get_obj(), "txid");
972  UniValue indexValue = find_value(params[0].get_obj(), "index");
973 
974  if (!txidValue.isStr() || !indexValue.isNum()) {
975  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index");
976  }
977 
978  uint256 txid = ParseHashV(txidValue, "txid");
979  int outputIndex = indexValue.get_int();
980 
981  CSpentIndexKey key(txid, outputIndex);
982  CSpentIndexValue value;
983 
984  if (!GetSpentIndex(key, value)) {
985  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info");
986  }
987 
989  obj.push_back(Pair("txid", value.txid.GetHex()));
990  obj.push_back(Pair("index", (int)value.inputIndex));
991  obj.push_back(Pair("height", value.blockHeight));
992 
993  return obj;
994 }
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const
Definition: keystore.cpp:57
UniValue spork(const UniValue &params, bool fHelp)
Definition: misc.cpp:225
bool IsCrypted() const
Definition: crypter.h:153
unsigned int GetKeyPoolSize()
Definition: wallet.h:978
UniValue getaddressbalance(const UniValue &params, bool fHelp)
Definition: misc.cpp:809
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
Definition: standard.h:69
CMasternodeSync masternodeSync
CAmount GetAnonymizedBalance() const
Definition: wallet.cpp:2177
UniValue getaddresstxids(const UniValue &params, bool fHelp)
Definition: misc.cpp:865
bool GetAddressUnspent(uint160 addressHash, int type, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
bool IsValid() const
Definition: netbase.h:34
bool fDebug
Definition: util.cpp:124
bool IsValid() const
Definition: base58.cpp:247
#define strprintf
Definition: tinyformat.h:1011
unsigned int inputIndex
Definition: spentindex.h:42
CCriticalSection cs_wallet
Definition: wallet.h:672
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
Definition: pubkey.cpp:207
int64_t GetAssetStartTime()
bool isStr() const
Definition: univalue.h:81
const std::string CURRENCY_UNIT
Definition: amount.cpp:10
UniValue getaddressdeltas(const UniValue &params, bool fHelp)
Definition: misc.cpp:721
UniValue validateaddress(const UniValue &params, bool fHelp)
Definition: misc.cpp:270
void SetMockTime(int64_t nMockTimeIn)
Definition: utiltime.cpp:29
CCriticalSection cs_main
Definition: validation.cpp:62
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Definition: pubkey.h:27
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
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, vector< CTxDestination > &addressRet, int &nRequiredRet)
Definition: standard.cpp:194
CWallet * pwalletMain
bool IsHex(const string &str)
double GetDifficulty(const CBlockIndex *blockindex)
Definition: blockchain.cpp:32
int64_t GetTimeOffset()
Definition: timedata.cpp:27
int GetSporkIDByName(std::string strName)
Definition: spork.cpp:170
bool IsWinnersListSynced()
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
Definition: script.h:22
std::string GetSporkNameByID(int nSporkID)
Definition: spork.cpp:186
bool push_back(const UniValue &val)
Definition: univalue.cpp:176
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
GetPubKey implementation that also checks the mapHdPubKeys.
Definition: wallet.cpp:202
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:144
UniValue ValueFromAmount(const CAmount &amount)
Definition: server.cpp:122
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
CService proxy
Definition: netbase.h:36
std::string ToString() const
Definition: base58.cpp:193
int64_t get_int64() const
Definition: univalue.cpp:327
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
Definition: pubkey.cpp:187
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
Definition: wallet.h:993
int64_t CAmount
Definition: amount.h:14
bool GetHDChain(CHDChain &hdChainRet) const
Definition: crypter.cpp:525
uint256 GetHash()
Definition: hash.h:254
iterator end()
Definition: prevector.h:272
bool fLiteMode
Definition: util.cpp:109
#define LOCK2(cs1, cs2)
Definition: sync.h:169
CAmount GetBalance() const
Definition: wallet.cpp:2139
void push_back(const T &value)
Definition: prevector.h:381
int64_t GetOldestKeyPoolTime()
Definition: wallet.cpp:3933
std::string ToStringIPPort(bool fUseGetnameinfo=true) const
Definition: netaddress.cpp:559
CFeeRate minRelayTxFee
Definition: validation.cpp:94
vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
std::string GetAssetName()
#define LOCK(cs)
Definition: sync.h:168
CScript _createmultisig_redeemScript(const UniValue &params)
Definition: misc.cpp:340
static const int SPORK_END
Definition: spork.h:20
int64_t nWalletUnlockTime
Definition: rpcwallet.cpp:32
CAmount GetFeePerK() const
Definition: amount.h:47
Server is in safe mode, and command is not allowed in safe mode.
Definition: protocol.h:43
int Height() const
Definition: chain.h:397
vector< unsigned char > ParseHex(const char *psz)
const char * GetTxnOutputType(txnouttype t)
Definition: standard.cpp:24
bool isArray() const
Definition: univalue.h:83
UniValue createmultisig(const UniValue &params, bool fHelp)
Definition: misc.cpp:401
UniValue getinfo(const UniValue &params, bool fHelp)
Definition: misc.cpp:47
CChain chainActive
Definition: validation.cpp:65
Unexpected type was passed as parameter.
Definition: protocol.h:44
CScript GetScriptForDestination(const CTxDestination &dest)
Definition: standard.cpp:262
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: server.cpp:581
std::string HelpRequiringPassphrase()
Definition: rpcwallet.cpp:35
bool GetSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
Definition: univalue.h:166
std::map< CKeyID, CHDPubKey > mapHdPubKeys
Definition: wallet.h:757
bool pushKVs(const UniValue &obj)
Definition: univalue.cpp:205
uint256 ParseHashV(const UniValue &v, string strName)
Definition: server.cpp:132
bool UpdateSpork(int nSporkID, int64_t nValue, CConnman &connman)
Definition: spork.cpp:104
bool heightSort(std::pair< CAddressUnspentKey, CAddressUnspentValue > a, std::pair< CAddressUnspentKey, CAddressUnspentValue > b)
Definition: misc.cpp:573
CSporkManager sporkManager
Definition: spork.cpp:14
txnouttype
Definition: standard.h:45
bool getAddressIndex(std::vector< std::pair< uint160, int > > &addresses, std::vector< std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > > &results)
Definition: txmempool.cpp:470
CTxDestination Get() const
Definition: base58.cpp:260
void RPCTypeCheck(const UniValue &params, const list< UniValue::VType > &typesExpected, bool fAllowNull)
Definition: server.cpp:70
CTxMemPool mempool
UniValue getaddressmempool(const UniValue &params, bool fHelp)
Definition: misc.cpp:583
uint256 GetID() const
Definition: hdchain.h:111
std::string GetWarnings(const std::string &strFor)
bool IsCompressed() const
Check whether this is a compressed public key.
Definition: pubkey.h:169
void SwitchToNextAsset(CConnman &connman)
const CChainParams & Params()
static const int PROTOCOL_VERSION
Definition: version.h:13
bool isNum() const
Definition: univalue.h:82
bool IsBlockchainSynced()
std::string GetHex() const
Definition: uint256.cpp:21
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:103
const UniValue NullUniValue
Definition: univalue.cpp:78
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
bool GetKeyID(CKeyID &keyID) const
Definition: base58.cpp:291
void ExecuteSpork(int nSporkID, int nValue)
Definition: spork.cpp:75
std::map< CTxDestination, CAddressBookData > mapAddressBook
Definition: wallet.h:748
int get_int() const
Definition: univalue.cpp:317
iterator begin()
Definition: prevector.h:270
bool GetIndexKey(uint160 &hashBytes, int &type) const
Definition: base58.cpp:274
UniValue mnsync(const UniValue &params, bool fHelp)
Definition: misc.cpp:143
bool GetAddressIndex(uint160 addressHash, int type, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start, int end)
Definition: pubkey.h:37
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address)
Definition: misc.cpp:525
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Definition: standard.cpp:275
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:536
UniValue verifymessage(const UniValue &params, bool fHelp)
Definition: misc.cpp:444
Invalid IP/Subnet.
Definition: protocol.h:66
bool IsSporkActive(int nSporkID)
Definition: spork.cpp:120
static const int SPORK_START
Definition: spork.h:19
isminetype
Definition: wallet_ismine.h:17
bool isObject() const
Definition: univalue.h:84
UniValue setmocktime(const UniValue &params, bool fHelp)
Definition: misc.cpp:498
int64_t GetSporkValue(int nSporkID)
Definition: spork.cpp:148
const string strMessageMagic
Definition: validation.cpp:109
map< string, vector< string > > mapMultiArgs
Definition: util.cpp:123
static const int CLIENT_VERSION
Definition: clientversion.h:54
UniValue debug(const UniValue &params, bool fHelp)
Definition: misc.cpp:119
bool MineBlocksOnDemand() const
Definition: chainparams.h:71
bool IsMasternodeListSynced()
UniValue JSONRPCError(int code, const string &message)
Definition: protocol.cpp:57
bool getAddressesFromParams(const UniValue &params, std::vector< std::pair< uint160, int > > &addresses)
Definition: misc.cpp:537
size_t size() const
Definition: univalue.h:69
const UniValue & get_array() const
Definition: univalue.cpp:354
bool timestampSort(std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > a, std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > b)
Definition: misc.cpp:578
std::string get_str() const
Definition: univalue.cpp:310
map< string, string > mapArgs
Definition: util.cpp:122
result
Definition: rpcuser.py:37
std::vector< UniValue > getValues() const
Definition: univalue.cpp:296