PIVX Core  5.6.99
P2P Digital Currency
misc.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-2022 The PIVX Core developers
5 // Distributed under the MIT software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 
8 #include "clientversion.h"
9 #include "httpserver.h"
10 #include "key_io.h"
11 #include "sapling/key_io_sapling.h"
12 #include "masternode-sync.h"
13 #include "messagesigner.h"
14 #include "net.h"
15 #include "netbase.h"
17 #include "rpc/server.h"
18 #include "spork.h"
19 #include "timedata.h"
21 #include "util/system.h"
22 #ifdef ENABLE_WALLET
23 #include "wallet/rpcwallet.h"
24 #include "wallet/wallet.h"
25 #endif
26 #include "warnings.h"
27 
28 #include <stdint.h>
29 
30 #include <univalue.h>
31 
32 extern std::vector<CSporkDef> sporkDefs;
33 
35 UniValue getsupplyinfo(const JSONRPCRequest& request);
36 
51 {
52  CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
53 
54  if (request.fHelp || request.params.size() != 0)
55  throw std::runtime_error(
56  "getinfo\n"
57  "\nReturns an object containing various state info.\n"
58 
59  "\nResult:\n"
60  "{\n"
61  " \"version\": xxxxx, (numeric) the server version\n"
62  " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
63  " \"services\": \"xxxx\", (string) The network services provided by this client\n"
64  " \"walletversion\": xxxxx, (numeric) the wallet version\n"
65  " \"balance\": xxxxxxx, (numeric) the total pivx balance of the wallet\n"
66  " \"staking status\": true|false, (boolean) if the wallet is staking or not\n"
67  " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
68  " \"timeoffset\": xxxxx, (numeric) the time offset\n"
69  " \"connections\": xxxxx, (numeric) the number of connections\n"
70  " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
71  " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
72  " \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
73  " \"moneysupply\": n (numeric) The sum of transparentsupply and shieldedsupply\n"
74  " \"transparentsupply\" : n (numeric) The sum of the value of all unspent outputs when the chainstate was\n"
75  " last flushed to disk (use getsupplyinfo to know the update-height, or\n"
76  " to trigger the money supply update/recalculation)"
77  " \"shieldsupply\": n (numeric) Chain tip shield pool value\n"
78  " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
79  " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
80  " \"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"
81  " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
82  " \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
83  " \"errors\": \"...\" (string) any error messages\n"
84  "}\n"
85 
86  "\nExamples:\n" +
87  HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", ""));
88 
89 #ifdef ENABLE_WALLET
90  LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr);
91 #else
92  LOCK(cs_main);
93 #endif
94 
95  std::string services;
96  for (int i = 0; i < 8; i++) {
97  uint64_t check = 1 << i;
98  if (g_connman->GetLocalServices() & check) {
99  switch (check) {
100  case NODE_NETWORK:
101  services+= "NETWORK/";
102  break;
103  case NODE_BLOOM:
105  services+= "BLOOM/";
106  break;
107  default:
108  services+= "UNKNOWN/";
109  }
110  }
111  }
112 
113  proxyType proxy;
114  GetProxy(NET_IPV4, proxy);
115 
117  obj.pushKV("version", CLIENT_VERSION);
118  obj.pushKV("protocolversion", PROTOCOL_VERSION);
119  obj.pushKV("services", services);
120 #ifdef ENABLE_WALLET
121  if (pwallet) {
122  obj.pushKV("walletversion", pwallet->GetVersion());
123  obj.pushKV("balance", ValueFromAmount(pwallet->GetAvailableBalance()));
124  obj.pushKV("staking status", (pwallet->pStakerStatus->IsActive() ? "Staking Active" : "Staking Not Active"));
125  }
126 #endif
127  obj.pushKV("blocks", (int)chainActive.Height());
128  obj.pushKV("timeoffset", GetTimeOffset());
129  if(g_connman) {
130  obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
131  }
132  obj.pushKV("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()));
133  obj.pushKV("difficulty", (double)GetDifficulty());
134  obj.pushKV("testnet", Params().IsTestnet());
135 
136  // Add (cached) money supply via getsupplyinfo RPC
137  UniValue supply_info = getsupplyinfo(JSONRPCRequest());
138  obj.pushKV("moneysupply", supply_info["totalsupply"]);
139  obj.pushKV("transparentsupply", supply_info["transparentsupply"]);
140  obj.pushKV("shieldsupply", supply_info["shieldsupply"]);
141 
142 #ifdef ENABLE_WALLET
143  if (pwallet) {
144  obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
145  size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
146  obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
147  }
148  if (pwallet && pwallet->IsCrypted())
149  obj.pushKV("unlocked_until", pwallet->nRelockTime);
150  obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()));
151 #endif
152  obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
153  obj.pushKV("errors", GetWarnings("statusbar"));
154  return obj;
155 }
156 
158 {
159  std::string strMode;
160  if (request.params.size() == 1)
161  strMode = request.params[0].get_str();
162 
163  if (request.fHelp || request.params.size() != 1 || (strMode != "status" && strMode != "reset")) {
164  throw std::runtime_error(
165  "mnsync \"status|reset\"\n"
166  "\nReturns the sync status or resets sync.\n"
167 
168  "\nArguments:\n"
169  "1. \"mode\" (string, required) either 'status' or 'reset'\n"
170 
171  "\nResult ('status' mode):\n"
172  "{\n"
173  " \"IsBlockchainSynced\": true|false, (boolean) 'true' if blockchain is synced\n"
174  " \"lastMasternodeList\": xxxx, (numeric) Timestamp of last MN list message\n"
175  " \"lastMasternodeWinner\": xxxx, (numeric) Timestamp of last MN winner message\n"
176  " \"lastBudgetItem\": xxxx, (numeric) Timestamp of last MN budget message\n"
177  " \"lastFailure\": xxxx, (numeric) Timestamp of last failed sync\n"
178  " \"nCountFailures\": n, (numeric) Number of failed syncs (total)\n"
179  " \"sumMasternodeList\": n, (numeric) Number of MN list messages (total)\n"
180  " \"sumMasternodeWinner\": n, (numeric) Number of MN winner messages (total)\n"
181  " \"sumBudgetItemProp\": n, (numeric) Number of MN budget messages (total)\n"
182  " \"sumBudgetItemFin\": n, (numeric) Number of MN budget finalization messages (total)\n"
183  " \"countMasternodeList\": n, (numeric) Number of MN list messages (local)\n"
184  " \"countMasternodeWinner\": n, (numeric) Number of MN winner messages (local)\n"
185  " \"countBudgetItemProp\": n, (numeric) Number of MN budget messages (local)\n"
186  " \"countBudgetItemFin\": n, (numeric) Number of MN budget finalization messages (local)\n"
187  " \"RequestedMasternodeAssets\": n, (numeric) Status code of last sync phase\n"
188  " \"RequestedMasternodeAttempt\": n, (numeric) Status code of last sync attempt\n"
189  "}\n"
190 
191  "\nResult ('reset' mode):\n"
192  "\"status\" (string) 'success'\n"
193 
194  "\nExamples:\n" +
195  HelpExampleCli("mnsync", "\"status\"") + HelpExampleRpc("mnsync", "\"status\""));
196  }
197 
198  if (strMode == "status") {
200 
201  obj.pushKV("IsBlockchainSynced", g_tiertwo_sync_state.IsBlockchainSynced());
202  obj.pushKV("lastMasternodeList", g_tiertwo_sync_state.GetlastMasternodeList());
203  obj.pushKV("lastMasternodeWinner", g_tiertwo_sync_state.GetlastMasternodeWinner());
204  obj.pushKV("lastBudgetItem", g_tiertwo_sync_state.GetlastBudgetItem());
205  obj.pushKV("lastFailure", masternodeSync.lastFailure);
206  obj.pushKV("nCountFailures", masternodeSync.nCountFailures);
207  obj.pushKV("sumMasternodeList", masternodeSync.sumMasternodeList);
208  obj.pushKV("sumMasternodeWinner", masternodeSync.sumMasternodeWinner);
209  obj.pushKV("sumBudgetItemProp", masternodeSync.sumBudgetItemProp);
210  obj.pushKV("sumBudgetItemFin", masternodeSync.sumBudgetItemFin);
211  obj.pushKV("countMasternodeList", masternodeSync.countMasternodeList);
212  obj.pushKV("countMasternodeWinner", masternodeSync.countMasternodeWinner);
213  obj.pushKV("countBudgetItemProp", masternodeSync.countBudgetItemProp);
214  obj.pushKV("countBudgetItemFin", masternodeSync.countBudgetItemFin);
215  obj.pushKV("RequestedMasternodeAssets", g_tiertwo_sync_state.GetSyncPhase());
216  obj.pushKV("RequestedMasternodeAttempt", masternodeSync.RequestedMasternodeAttempt);
217 
218  return obj;
219  }
220 
221  if (strMode == "reset") {
223  return "success";
224  }
225  return "failure";
226 }
227 
228 #ifdef ENABLE_WALLET
229 class DescribeAddressVisitor : public boost::static_visitor<UniValue>
230 {
231 public:
232  CWallet * const pwallet;
233 
234  explicit DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {}
235 
236  UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
237 
238  UniValue operator()(const CKeyID &keyID) const {
240  CPubKey vchPubKey;
241  obj.pushKV("isscript", false);
242  if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) {
243  obj.pushKV("pubkey", HexStr(vchPubKey));
244  obj.pushKV("iscompressed", vchPubKey.IsCompressed());
245  }
246  return obj;
247  }
248 
249  UniValue operator()(const CExchangeKeyID &keyID) const {
251  CPubKey vchPubKey;
252  obj.pushKV("isscript", false);
253  if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) {
254  obj.pushKV("exchangepubkey", HexStr(vchPubKey));
255  obj.pushKV("iscompressed", vchPubKey.IsCompressed());
256  }
257  return obj;
258  }
259 
260  UniValue operator()(const CScriptID &scriptID) const {
262  obj.pushKV("isscript", true);
263  CScript subscript;
264  if (pwallet && pwallet->GetCScript(scriptID, subscript)) {
265  std::vector<CTxDestination> addresses;
266  txnouttype whichType;
267  int nRequired;
268  ExtractDestinations(subscript, whichType, addresses, nRequired);
269  obj.pushKV("script", GetTxnOutputType(whichType));
270  obj.pushKV("hex", HexStr(subscript));
272  for (const CTxDestination& addr : addresses)
273  a.push_back(EncodeDestination(addr));
274  obj.pushKV("addresses", a);
275  if (whichType == TX_MULTISIG)
276  obj.pushKV("sigsrequired", nRequired);
277  }
278  return obj;
279  }
280 };
281 #endif
282 
283 /*
284  Used for updating/reading spork settings on the network
285 */
287 {
288  if (request.params.size() == 1 && request.params[0].get_str() == "show") {
290  for (const auto& sporkDef : sporkDefs) {
291  ret.pushKV(sporkDef.name, sporkManager.GetSporkValue(sporkDef.sporkId));
292  }
293  return ret;
294  } else if (request.params.size() == 1 && request.params[0].get_str() == "active") {
296  for (const auto& sporkDef : sporkDefs) {
297  ret.pushKV(sporkDef.name, sporkManager.IsSporkActive(sporkDef.sporkId));
298  }
299  return ret;
300  } else if (request.params.size() == 2) {
301  // advanced mode, update spork values
302  SporkId nSporkID = sporkManager.GetSporkIDByName(request.params[0].get_str());
303  if (nSporkID == SPORK_INVALID) {
304  throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid spork name");
305  }
306 
307  // SPORK VALUE
308  int64_t nValue = request.params[1].get_int64();
309 
310  //broadcast new spork
311  if (sporkManager.UpdateSpork(nSporkID, nValue)) {
312  return "success";
313  } else {
314  return "failure";
315  }
316  }
317 
318  throw std::runtime_error(
319  "spork \"name\" ( value )\n"
320  "\nReturn spork values or their active state.\n"
321 
322  "\nArguments:\n"
323  "1. \"name\" (string, required) \"show\" to show values, \"active\" to show active state.\n"
324  " When set up as a spork signer, the name of the spork can be used to update it's value.\n"
325  "2. value (numeric, required when updating a spork) The new value for the spork.\n"
326 
327  "\nResult (show):\n"
328  "{\n"
329  " \"spork_name\": nnn (key/value) Key is the spork name, value is it's current value.\n"
330  " ,...\n"
331  "}\n"
332 
333  "\nResult (active):\n"
334  "{\n"
335  " \"spork_name\": true|false (key/value) Key is the spork name, value is a boolean for it's active state.\n"
336  " ,...\n"
337  "}\n"
338 
339  "\nResult (name):\n"
340  " \"success|failure\" (string) Whether or not the update succeeded.\n"
341 
342  "\nExamples:\n" +
343  HelpExampleCli("spork", "show") + HelpExampleRpc("spork", "show"));
344 }
345 
346 // Every possibly address
347 typedef boost::variant<libzcash::InvalidEncoding, libzcash::SaplingPaymentAddress, CTxDestination> PPaymentAddress;
348 
349 class DescribePaymentAddressVisitor : public boost::static_visitor<UniValue>
350 {
351 public:
352  explicit DescribePaymentAddressVisitor(CWallet *_pwallet, bool _isStaking) : pwallet(_pwallet), isStaking(_isStaking) {}
354 
357  obj.pushKV("diversifier", HexStr(zaddr.d));
358  obj.pushKV("diversifiedtransmissionkey", zaddr.pk_d.GetHex());
359 #ifdef ENABLE_WALLET
360  if (pwallet) {
361  obj.pushKV("ismine", pwallet->HaveSpendingKeyForPaymentAddress(zaddr));
362  }
363 #endif
364  return obj;
365  }
366 
367  UniValue operator()(const CTxDestination &dest) const {
369  CScript scriptPubKey = GetScriptForDestination(dest);
370  ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
371 
372 #ifdef ENABLE_WALLET
373  isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
374  ret.pushKV("ismine", bool(mine & (ISMINE_SPENDABLE_ALL | ISMINE_COLD)));
375  ret.pushKV("isstaking", isStaking);
376  ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
377  UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
378  ret.pushKVs(detail);
379  if (pwallet && pwallet->HasAddressBook(dest))
380  ret.pushKV("label", pwallet->GetNameForAddressBookEntry(dest));
381 #endif
382  return ret;
383  }
384 
385 private:
386  CWallet * const pwallet;
387  bool isStaking{false};
388 };
389 
391 {
392  CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
393 
394  if (request.fHelp || request.params.size() != 1)
395  throw std::runtime_error(
396  "validateaddress \"pivxaddress\"\n"
397  "\nReturn information about the given pivx address.\n"
398 
399  "\nArguments:\n"
400  "1. \"pivxaddress\" (string, required) The pivx address to validate\n"
401 
402  "\nResult:\n"
403  "{\n"
404  " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
405  " \"address\" : \"pivxaddress\", (string) The pivx address validated\n"
406  " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address -only if is standard address-\n"
407  " \"ismine\" : true|false, (boolean) If the address is yours or not\n"
408  " \"isstaking\" : true|false, (boolean) If the address is a staking address for PIVX cold staking -only if is standard address-\n"
409  " \"iswatchonly\" : true|false, (boolean) If the address is watchonly -only if standard address-\n"
410  " \"isscript\" : true|false, (boolean) If the key is a script -only if standard address-\n"
411  " \"hex\" : \"hex\", (string, optional) The redeemscript for the P2SH address -only if standard address-\n"
412  " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key -only if standard address-\n"
413  " \"iscompressed\" : true|false, (boolean) If the address is compressed -only if standard address-\n"
414  " \"label\" : \"label\" (string) The label associated with the address, \"\" is the default label\n"
415  // Sapling
416  " \"diversifier\" : \"hex\", (string) [sapling] The hex value of the diversifier, d -only if is sapling address-\n"
417  " \"diversifiedtransmissionkey\" : \"hex\", (string) [sapling] The hex value of pk_d -only if is sapling address-\n"
418  "}\n"
419 
420  "\nExamples:\n" +
421  HelpExampleCli("validateaddress", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\"") +
422  HelpExampleCli("validateaddress", "\"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\"") +
423  HelpExampleRpc("validateaddress", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\""));
424 
425 #ifdef ENABLE_WALLET
426  LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr);
427 #else
428  LOCK(cs_main);
429 #endif
430 
431  std::string strAddress = request.params[0].get_str();
432 
433  // First check if it's a regular address
434  bool isStaking = false;
435  bool isExchange = false;
436  CTxDestination dest = DecodeDestination(strAddress, isStaking, isExchange);
437  bool isValid = IsValidDestination(dest);
438 
439  PPaymentAddress finalAddress;
440  if (!isValid) {
441  isValid = KeyIO::IsValidPaymentAddressString(strAddress);
442  if (isValid) finalAddress = KeyIO::DecodePaymentAddress(strAddress);
443  } else {
444  finalAddress = dest;
445  }
446 
448  ret.pushKV("isvalid", isValid);
449  if (isValid) {
450  ret.pushKV("address", strAddress);
451  UniValue detail = boost::apply_visitor(DescribePaymentAddressVisitor(pwallet, isStaking), finalAddress);
452  ret.pushKVs(detail);
453  }
454 
455  return ret;
456 }
457 
461 CScript _createmultisig_redeemScript(CWallet * const pwallet, const UniValue& params)
462 {
463  int nRequired = params[0].get_int();
464  const UniValue& keys = params[1].get_array();
465 
466  // Gather public keys
467  if (nRequired < 1)
468  throw std::runtime_error("a multisignature address must require at least one key to redeem");
469  if ((int)keys.size() < nRequired)
470  throw std::runtime_error(
471  strprintf("not enough keys supplied "
472  "(got %u keys, but need at least %d to redeem)",
473  keys.size(), nRequired));
474  if (keys.size() > 16)
475  throw std::runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
476  std::vector<CPubKey> pubkeys;
477  pubkeys.resize(keys.size());
478  for (unsigned int i = 0; i < keys.size(); i++) {
479  const std::string& ks = keys[i].get_str();
480 #ifdef ENABLE_WALLET
481  // Case 1: PIVX address and we have full public key:
483  if (pwallet && IsValidDestination(dest)) {
484  const CKeyID* keyID = boost::get<CKeyID>(&dest);
485  if (!keyID) {
486  throw std::runtime_error(
487  strprintf("%s does not refer to a key", ks));
488  }
489  CPubKey vchPubKey;
490  if (!pwallet->GetPubKey(*keyID, vchPubKey))
491  throw std::runtime_error(
492  strprintf("no full public key for address %s", ks));
493  if (!vchPubKey.IsFullyValid())
494  throw std::runtime_error(" Invalid public key: " + ks);
495  pubkeys[i] = vchPubKey;
496  }
497 
498  // Case 2: hex public key
499  else
500 #endif
501  if (IsHex(ks)) {
502  CPubKey vchPubKey(ParseHex(ks));
503  if (!vchPubKey.IsFullyValid())
504  throw std::runtime_error(" Invalid public key: " + ks);
505  pubkeys[i] = vchPubKey;
506  } else {
507  throw std::runtime_error(" Invalid public key: " + ks);
508  }
509  }
510  CScript result = GetScriptForMultisig(nRequired, pubkeys);
511 
512  if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
513  throw std::runtime_error(
514  strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE));
515 
516  return result;
517 }
518 
520 {
521  CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
522 
523  if (request.fHelp || request.params.size() < 2 || request.params.size() > 2)
524  throw std::runtime_error(
525  "createmultisig nrequired [\"key\",...]\n"
526  "\nCreates a multi-signature address with n signature of m keys required.\n"
527  "It returns a json object with the address and redeemScript.\n"
528 
529  "\nArguments:\n"
530  "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
531  "2. \"keys\" (string, required) A json array of keys which are pivx addresses or hex-encoded public keys\n"
532  " [\n"
533  " \"key\" (string) pivx address or hex-encoded public key\n"
534  " ,...\n"
535  " ]\n"
536 
537  "\nResult:\n"
538  "{\n"
539  " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
540  " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
541  "}\n"
542 
543  "\nExamples:\n"
544  "\nCreate a multisig address from 2 addresses\n" +
545  HelpExampleCli("createmultisig", "2 \"[\\\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\\\",\\\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\\\"]\"") +
546  "\nAs a json rpc call\n" +
547  HelpExampleRpc("createmultisig", "2, \"[\\\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\\\",\\\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\\\"]\""));
548 
549  // Construct using pay-to-script-hash:
550  CScript inner = _createmultisig_redeemScript(pwallet, request.params);
551  CScriptID innerID(inner);
552 
553  UniValue result(UniValue::VOBJ);
554  result.pushKV("address", EncodeDestination(innerID));
555  result.pushKV("redeemScript", HexStr(inner));
556 
557  return result;
558 }
559 
561 {
562  if (request.fHelp || request.params.size() != 3)
563  throw std::runtime_error(
564  "verifymessage \"pivxaddress\" \"signature\" \"message\"\n"
565  "\nVerify a signed message\n"
566 
567  "\nArguments:\n"
568  "1. \"pivxaddress\" (string, required) The pivx address to use for the signature.\n"
569  "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
570  "3. \"message\" (string, required) The message that was signed.\n"
571 
572  "\nResult:\n"
573  "true|false (boolean) If the signature is verified or not.\n"
574 
575  "\nExamples:\n"
576  "\nUnlock the wallet for 30 seconds\n" +
577  HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
578  "\nCreate the signature\n" +
579  HelpExampleCli("signmessage", "\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\" \"my message\"") +
580  "\nVerify the signature\n" +
581  HelpExampleCli("verifymessage", "\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\" \"signature\" \"my message\"") +
582  "\nAs json rpc\n" +
583  HelpExampleRpc("verifymessage", "\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\", \"signature\", \"my message\""));
584 
585  LOCK(cs_main);
586 
587  std::string strAddress = request.params[0].get_str();
588  std::string strSign = request.params[1].get_str();
589  std::string strMessage = request.params[2].get_str();
590 
591  CTxDestination destination = DecodeDestination(strAddress);
592  if (!IsValidDestination(destination))
593  throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
594 
595  const CKeyID* keyID = boost::get<CKeyID>(&destination);
596  if (!keyID) {
597  throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
598  }
599 
600  bool fInvalid = false;
601  std::vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
602 
603  if (fInvalid)
604  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
605 
606  std::string strError;
607  return CMessageSigner::VerifyMessage(*keyID, vchSig, strMessage, strError);
608 }
609 
611 {
612  if (request.fHelp || request.params.size() != 1)
613  throw std::runtime_error(
614  "setmocktime timestamp\n"
615  "\nSet the local time to given timestamp (-regtest only)\n"
616 
617  "\nArguments:\n"
618  "1. timestamp (numeric, required) Unix seconds-since-epoch timestamp\n"
619  " Pass 0 to go back to using the system time.");
620 
621  if (!Params().IsRegTestNet())
622  throw std::runtime_error("setmocktime for regression testing (-regtest mode) only");
623 
624  // For now, don't change mocktime if we're in the middle of validation, as
625  // this could have an effect on mempool time-based eviction, as well as
626  // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
627  // TODO: figure out the right way to synchronize around mocktime, and
628  // ensure all callsites of GetTime() are accessing this safely.
629  LOCK(cs_main);
630 
631  RPCTypeCheck(request.params, {UniValue::VNUM});
632  SetMockTime(request.params[0].get_int64());
633 
634  return NullUniValue;
635 }
636 
637 void EnableOrDisableLogCategories(UniValue cats, bool enable) {
638  cats = cats.get_array();
639  for (unsigned int i = 0; i < cats.size(); ++i) {
640  std::string cat = cats[i].get_str();
641 
642  bool success;
643  if (enable) {
644  success = g_logger->EnableCategory(cat);
645  } else {
646  success = g_logger->DisableCategory(cat);
647  }
648 
649  if (!success)
650  throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat);
651  }
652 }
653 
655 {
656  if (request.fHelp || request.params.size() > 2) {
657  throw std::runtime_error(
658  "logging [include,...] ( [exclude,...] )\n"
659  "Gets and sets the logging configuration.\n"
660  "When called without an argument, returns the list of categories that are currently being debug logged.\n"
661  "When called with arguments, adds or removes categories from debug logging.\n"
662  "The valid logging categories are: " + ListLogCategories() + "\n"
663  "libevent logging is configured on startup and cannot be modified by this RPC during runtime."
664 
665  "Arguments:\n"
666  "1. \"include\" (array of strings) add debug logging for these categories.\n"
667  "2. \"exclude\" (array of strings) remove debug logging for these categories.\n"
668 
669  "\nResult:\n"
670  "{ (object): a JSON object of the logging categories that are active.\n"
671  " \"category\": fEnabled, (key/value) Key is the category name, value is a boolean of it's active state.\n"
672  " ...,\n"
673  "}\n"
674 
675  "\nExamples:\n"
676  + HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
677  + HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"")
678  );
679  }
680 
681  uint32_t original_log_categories = g_logger->GetCategoryMask();
682  if (request.params.size() > 0 && request.params[0].isArray()) {
683  EnableOrDisableLogCategories(request.params[0], true);
684  }
685 
686  if (request.params.size() > 1 && request.params[1].isArray()) {
687  EnableOrDisableLogCategories(request.params[1], false);
688  }
689  uint32_t updated_log_categories = g_logger->GetCategoryMask();
690  uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
691 
692  // Update libevent logging if BCLog::LIBEVENT has changed.
693  // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
694  // in which case we should clear the BCLog::LIBEVENT flag.
695  // Throw an error if the user has explicitly asked to change only the libevent
696  // flag and it failed.
697  if (changed_log_categories & BCLog::LIBEVENT) {
700  if (changed_log_categories == BCLog::LIBEVENT) {
701  throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
702  }
703  }
704  }
705 
706  UniValue result(UniValue::VOBJ);
707  std::vector<CLogCategoryActive> vLogCatActive = ListActiveLogCategories();
708  for (const auto& logCatActive : vLogCatActive) {
709  result.pushKV(logCatActive.category, logCatActive.active);
710  }
711 
712  return result;
713 }
714 
715 static UniValue RPCLockedMemoryInfo()
716 {
719  obj.pushKV("used", uint64_t(stats.used));
720  obj.pushKV("free", uint64_t(stats.free));
721  obj.pushKV("total", uint64_t(stats.total));
722  obj.pushKV("locked", uint64_t(stats.locked));
723  obj.pushKV("chunks_used", uint64_t(stats.chunks_used));
724  obj.pushKV("chunks_free", uint64_t(stats.chunks_free));
725  return obj;
726 }
727 
729 {
730  /* Please, avoid using the word "pool" here in the RPC interface or help,
731  * as users will undoubtedly confuse it with the other "memory pool"
732  */
733  if (request.fHelp || request.params.size() != 0)
734  throw std::runtime_error(
735  "getmemoryinfo\n"
736  "Returns an object containing information about memory usage.\n"
737  "\nResult:\n"
738  "{\n"
739  " \"locked\": { (json object) Information about locked memory manager\n"
740  " \"used\": xxxxx, (numeric) Number of bytes used\n"
741  " \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n"
742  " \"total\": xxxxxxx, (numeric) Total number of bytes managed\n"
743  " \"locked\": xxxxxx, (numeric) Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk.\n"
744  " \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n"
745  " \"chunks_free\": xxxxx, (numeric) Number unused chunks\n"
746  " }\n"
747  "}\n"
748  "\nExamples:\n"
749  + HelpExampleCli("getmemoryinfo", "")
750  + HelpExampleRpc("getmemoryinfo", "")
751  );
753  obj.pushKV("locked", RPCLockedMemoryInfo());
754  return obj;
755 }
756 
757 UniValue echo(const JSONRPCRequest& request)
758 {
759  if (request.fHelp)
760  throw std::runtime_error(
761  "echo|echojson \"message\" ...\n"
762  "\nSimply echo back the input arguments. This command is for testing.\n"
763  "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in"
764  "pivx-cli and the GUI. There is no server-side difference."
765  );
766 
767  return request.params;
768 }
769 
770 // mnconnect command operation types
771 const char* SINGLE_CONN = "single_conn";
772 const char* QUORUM_MEMBERS_CONN = "quorum_members_conn";
773 const char* IQR_MEMBERS_CONN = "iqr_members_conn";
774 const char* PROBE_CONN = "probe_conn";
775 const char* CLEAR_CONN = "clear_conn";
776 
777 /* What essentially does is add a pending MN connection
778  * Can be in the following forms:
779  * 1) Direct single DMN connection.
780  * 2) Quorum members connection (set of DMNs to connect).
781  * 3) Quorum relay members connections (set of DMNs to connect and relay intra-quorum messages).
782  * 4) Probe DMN connection.
783  * 5) Clear tier two net connections cache
784 **/
786 {
787  if (request.fHelp || request.params.empty() || request.params.size() > 4) {
788  throw std::runtime_error(
789  "mnconnect \"op_type\" (\"[pro_tx_hash, pro_tx_hash,..]\" llmq_type \"quorum_hash\")\n"
790  "\nAdd manual quorum members connections for internal testing purposes of the tier two p2p network layer\n"
791  );
792  }
793 
794  const auto& chainparams = Params();
795  if (!chainparams.IsRegTestNet())
796  throw std::runtime_error("mnconnect for regression testing (-regtest mode) only");
797 
798  // Connection type
799  RPCTypeCheck(request.params, {UniValue::VSTR});
800  const std::string& op_type = request.params[0].get_str();
801 
802  // DMNs pro_tx list
803  std::set<uint256> set_dmn_protxhash;
804  if (request.params.size() > 1) {
806  const auto& array{request.params[1].get_array()};
807  for (unsigned int i = 0; i < array.size(); i++) {
808  set_dmn_protxhash.emplace(ParseHashV(array[i], strprintf("pro_tx_hash (index %d)", i)));
809  }
810  }
811 
813  if (request.params.size() > 2) {
815  llmq_type = (Consensus::LLMQType)request.params[2].get_int();
816  }
817 
818  uint256 quorum_hash;
819  if (request.params.size() > 3) {
820  quorum_hash = ParseHashV(request.params[3], "quorum_hash");
821  }
822 
823  const auto& mn_connan = g_connman->GetTierTwoConnMan();
824  if (op_type == SINGLE_CONN) {
825  for (const auto& protxhash : set_dmn_protxhash) {
826  // if the connection exist or if the dmn doesn't exist,
827  // it will simply not even try to connect to it.
828  mn_connan->addPendingMasternode(protxhash);
829  }
830  return true;
831  } else if (op_type == QUORUM_MEMBERS_CONN) {
832  mn_connan->setQuorumNodes(llmq_type, quorum_hash, set_dmn_protxhash);
833  return true;
834  } else if (op_type == IQR_MEMBERS_CONN) {
835  mn_connan->setMasternodeQuorumRelayMembers(llmq_type, quorum_hash, set_dmn_protxhash);
836  return true;
837  } else if (op_type == PROBE_CONN) {
838  mn_connan->addPendingProbeConnections(set_dmn_protxhash);
839  return true;
840  } else if (op_type == CLEAR_CONN) {
841  mn_connan->clear();
842  return true;
843  }
844  return false;
845 }
846 
847 // clang-format off
848 static const CRPCCommand commands[] =
849 { // category name actor (function) okSafe argNames
850  // --------------------- ------------------------ ----------------------- ------ --------
851  { "control", "getinfo", &getinfo, true, {} }, /* uses wallet if enabled */
852  { "control", "getmemoryinfo", &getmemoryinfo, true, {} },
853  { "control", "mnsync", &mnsync, true, {"mode"} },
854  { "control", "spork", &spork, true, {"name","value"} },
855 
856  { "util", "createmultisig", &createmultisig, true, {"nrequired","keys"} },
857  { "util", "logging", &logging, true, {"include", "exclude"} },
858  { "util", "validateaddress", &validateaddress, true, {"pivxaddress"} }, /* uses wallet if enabled */
859  { "util", "verifymessage", &verifymessage, true, {"pivxaddress","signature","message"} },
860 
862  { "hidden", "echo", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"} },
863  { "hidden", "echojson", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"} },
864  { "hidden", "setmocktime", &setmocktime, true, {"timestamp"} },
865  { "hidden", "mnconnect", &mnconnect, true, {"op_type", "mn_list", "llmq_type", "quorum_hash"} },
866 };
867 // clang-format on
868 
870 {
871  for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
872  tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
873 }
double GetDifficulty(const CBlockIndex *blockindex)
Definition: blockchain.cpp:67
const CChainParams & Params()
Return the currently selected parameters.
bool WillLogCategory(LogFlags category) const
Definition: logging.cpp:82
void EnableCategory(LogFlags flag)
Definition: logging.cpp:56
uint32_t GetCategoryMask() const
Definition: logging.h:111
void DisableCategory(LogFlags flag)
Definition: logging.cpp:69
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const
Definition: keystore.cpp:57
int Height() const
Return the maximal height in the chain.
Definition: chain.h:450
@ CONNECTIONS_ALL
Definition: net.h:152
bool IsCrypted() const
Definition: crypter.h:154
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
Definition: crypter.cpp:215
A reference to a CKey: the Hash160 of its serialized public key, special case for exchange key.
Definition: pubkey.h:30
CAmount GetFeePerK() const
Definition: feerate.h:29
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:21
int RequestedMasternodeAttempt
static bool VerifyMessage(const CPubKey &pubkey, const std::vector< unsigned char > &vchSig, const std::string &strMessage, std::string &strErrorRet)
Verify the message signature, returns true if successful.
An encapsulated public key.
Definition: pubkey.h:44
bool IsCompressed() const
Check whether this is a compressed public key.
Definition: pubkey.h:192
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
Definition: pubkey.cpp:210
std::string name
Definition: server.h:137
PIVX RPC command dispatcher.
Definition: server.h:147
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:314
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:381
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:24
std::string ToStringIPPort() const
Definition: netaddress.cpp:945
bool UpdateSpork(SporkId nSporkID, int64_t nValue)
Definition: spork.cpp:193
SporkId GetSporkIDByName(std::string strName)
Definition: spork.cpp:245
int64_t GetSporkValue(SporkId nSporkID)
Definition: spork.cpp:226
bool IsSporkActive(SporkId nSporkID)
Definition: spork.cpp:220
bool IsActive() const
Definition: wallet.h:213
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:577
CStakerStatus * pStakerStatus
Definition: wallet.h:737
RecursiveMutex cs_wallet
Definition: wallet.h:720
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Definition: wallet.cpp:4701
int64_t nRelockTime
Lock Wallet Holds a timestamp at which point the wallet is scheduled (externally) to be relocked.
Definition: wallet.h:1009
bool HaveSpendingKeyForPaymentAddress(const libzcash::SaplingPaymentAddress &zaddr) const
Returns true if the wallet contains the spending key.
Definition: wallet.cpp:4738
UniValue operator()(const libzcash::SaplingPaymentAddress &zaddr) const
Definition: misc.cpp:355
DescribePaymentAddressVisitor(CWallet *_pwallet, bool _isStaking)
Definition: misc.cpp:352
UniValue operator()(const CTxDestination &dest) const
Definition: misc.cpp:367
CWallet *const pwallet
Definition: misc.cpp:386
UniValue operator()(const libzcash::InvalidEncoding &zaddr) const
Definition: misc.cpp:353
UniValue params
Definition: server.h:47
bool fHelp
Definition: server.h:48
Stats stats() const
Get pool usage statistics.
Definition: lockedpool.cpp:336
static LockedPoolManager & Instance()
Return the current instance, or create it once.
Definition: lockedpool.h:223
bool IsBlockchainSynced() const
int64_t GetlastMasternodeWinner() const
int64_t GetlastMasternodeList() const
int GetSyncPhase() const
int64_t GetlastBudgetItem() const
const std::string & get_str() const
bool isArray() const
Definition: univalue.h:83
@ VOBJ
Definition: univalue.h:21
@ VARR
Definition: univalue.h:21
@ VNUM
Definition: univalue.h:21
int64_t get_int64() const
size_t size() const
Definition: univalue.h:68
bool empty() const
Definition: univalue.h:66
bool pushKVs(const UniValue &obj)
Definition: univalue.cpp:146
const UniValue & get_array() const
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
int get_int() const
std::string GetHex() const
Definition: uint256.cpp:21
Sapling functions.
Definition: address.h:30
size_type size() const
Definition: prevector.h:277
bool IsValid() const
Definition: netbase.h:35
CService proxy
Definition: netbase.h:37
256-bit opaque blob.
Definition: uint256.h:138
const std::string CURRENCY_UNIT
Definition: feerate.cpp:11
int64_t GetOldestKeyPoolTime()
Definition: wallet.cpp:3757
size_t KeypoolCountExternalKeys()
Definition: wallet.cpp:3729
std::string GetNameForAddressBookEntry(const CWDestination &address) const
Definition: wallet.cpp:3686
bool HasAddressBook(const CWDestination &address) const
Definition: wallet.cpp:3710
CAmount GetAvailableBalance(bool fIncludeDelegated=true, bool fIncludeShielded=true) const
Definition: wallet.cpp:2162
bool UpdateHTTPServerLogging(bool enable)
Change logging level for libevent.
Definition: httpserver.cpp:414
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:90
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
Definition: ismine.cpp:29
isminetype
IsMine() return codes.
Definition: ismine.h:19
@ ISMINE_SPENDABLE_ALL
Definition: ismine.h:33
@ ISMINE_COLD
Indicates that we have the staking key of a P2CS.
Definition: ismine.h:24
@ ISMINE_NO
Definition: ismine.h:20
@ ISMINE_WATCH_ONLY
Definition: ismine.h:21
@ LOCK
Definition: lockunlock.h:16
std::vector< CLogCategoryActive > ListActiveLogCategories()
Returns a vector of the active log categories.
Definition: logging.cpp:163
BCLog::Logger *const g_logger
NOTE: the logger instances is leaked on exit.
Definition: logging.cpp:26
std::string ListLogCategories()
Returns a string with the supported log categories.
Definition: logging.cpp:148
CMasternodeSync masternodeSync
UniValue createmultisig(const JSONRPCRequest &request)
Definition: misc.cpp:519
UniValue verifymessage(const JSONRPCRequest &request)
Definition: misc.cpp:560
UniValue logging(const JSONRPCRequest &request)
Definition: misc.cpp:654
CScript _createmultisig_redeemScript(CWallet *const pwallet, const UniValue &params)
Used by addmultisigaddress / createmultisig:
Definition: misc.cpp:461
UniValue validateaddress(const JSONRPCRequest &request)
Definition: misc.cpp:390
const char * PROBE_CONN
Definition: misc.cpp:774
void RegisterMiscRPCCommands(CRPCTable &tableRPC)
Register miscellaneous RPC commands.
Definition: misc.cpp:869
UniValue getinfo(const JSONRPCRequest &request)
Definition: misc.cpp:50
UniValue mnconnect(const JSONRPCRequest &request)
Definition: misc.cpp:785
const char * QUORUM_MEMBERS_CONN
Definition: misc.cpp:772
const char * SINGLE_CONN
Definition: misc.cpp:771
const char * IQR_MEMBERS_CONN
Definition: misc.cpp:773
UniValue getmemoryinfo(const JSONRPCRequest &request)
Definition: misc.cpp:728
const char * CLEAR_CONN
Definition: misc.cpp:775
UniValue setmocktime(const JSONRPCRequest &request)
Definition: misc.cpp:610
UniValue getsupplyinfo(const JSONRPCRequest &request)
getinfo depends on getsupplyinfo defined in rpc/blockchain.cpp
Definition: blockchain.cpp:701
UniValue mnsync(const JSONRPCRequest &request)
Definition: misc.cpp:157
boost::variant< libzcash::InvalidEncoding, libzcash::SaplingPaymentAddress, CTxDestination > PPaymentAddress
Definition: misc.cpp:347
void EnableOrDisableLogCategories(UniValue cats, bool enable)
Definition: misc.cpp:637
std::vector< CSporkDef > sporkDefs
Definition: spork.cpp:16
UniValue echo(const JSONRPCRequest &request)
Definition: misc.cpp:757
UniValue spork(const JSONRPCRequest &request)
Definition: misc.cpp:286
@ LIBEVENT
Definition: logging.h:54
LLMQType
Definition: params.h:90
@ LLMQ_NONE
Definition: params.h:91
bool IsValidPaymentAddressString(const std::string &str)
libzcash::PaymentAddress DecodePaymentAddress(const std::string &str)
bool IsValidDestination(const CWDestination &address)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
CWDestination DecodeDestination(const std::string &strAddress)
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:80
@ NET_IPV4
IPv4.
Definition: netaddress.h:49
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:605
@ NODE_BLOOM
Definition: protocol.h:321
@ NODE_NETWORK
Definition: protocol.h:318
@ NODE_BLOOM_WITHOUT_MN
Definition: protocol.h:325
UniValue JSONRPCError(int code, const std::string &message)
Definition: protocol.cpp:53
@ RPC_TYPE_ERROR
Server is in safe mode, and command is not allowed in safe mode.
Definition: protocol.h:43
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
Definition: protocol.h:46
@ RPC_INVALID_ADDRESS_OR_KEY
Unexpected type was passed as parameter.
Definition: protocol.h:44
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
Definition: rpcwallet.cpp:39
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
Definition: server.cpp:82
UniValue ValueFromAmount(const CAmount &amount)
Definition: server.cpp:128
std::string HelpExampleCli(std::string methodname, std::string args)
Definition: server.cpp:527
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:63
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
Definition: server.cpp:138
std::string HelpExampleRpc(std::string methodname, std::string args)
Definition: server.cpp:532
CRPCTable tableRPC
Definition: server.cpp:565
CSporkManager sporkManager
Definition: spork.cpp:29
SporkId
Definition: sporkid.h:14
@ SPORK_INVALID
Definition: sporkid.h:32
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
Definition: standard.cpp:195
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: standard.cpp:311
const char * GetTxnOutputType(txnouttype t)
Definition: standard.cpp:18
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a PIVX scriptPubKey for the given CTxDestination.
Definition: standard.cpp:278
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:72
txnouttype
Definition: standard.h:46
@ TX_MULTISIG
Definition: standard.h:52
Memory statistics.
Definition: lockedpool.h:147
#define LOCK2(cs1, cs2)
Definition: sync.h:221
TierTwoSyncState g_tiertwo_sync_state
int64_t GetTimeOffset()
"Never go to sea with two chronometers; take one or three." Our three time sources are:
Definition: timedata.cpp:30
#define strprintf
Definition: tinyformat.h:1056
const UniValue NullUniValue
Definition: univalue.cpp:13
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::vector< unsigned char > ParseHex(const char *psz)
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
bool IsHex(const std::string &str)
#define ARRAYLEN(array)
void SetMockTime(int64_t nMockTimeIn)
For testing.
Definition: utiltime.cpp:51
CFeeRate minRelayTxFee
Fees smaller than this (in upiv) are considered zero fee (for relaying, mining and transaction creati...
Definition: validation.cpp:108
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:84
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE)
Settings.
std::string GetWarnings(const std::string &strFor)
Definition: warnings.cpp:47