 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
22 #include <condition_variable>
31 static std::mutex cs_blockchange;
32 static std::condition_variable cond_blockchange;
43 if (blockindex == NULL) {
50 int nShift = (blockindex->
nBits >> 24) & 0xff;
53 (double)0x0000ffff / (
double)(blockindex->
nBits & 0x00ffffff);
71 int confirmations = -1;
75 result.
push_back(Pair(
"confirmations", confirmations));
87 if (blockindex->
pprev)
99 int confirmations = -1;
103 result.
push_back(Pair(
"confirmations", confirmations));
126 if (blockindex->
pprev)
135 std::string minetype =
"PoW";
142 result.
push_back(Pair(
"minetype", minetype));
149 bool auditResult =
true;
154 posBlockInfos.
push_back(objPoSBlockInfo);
157 result.
push_back(Pair(
"auditsuccess", auditResult?
"true":
"false"));
158 result.
push_back(Pair(
"posblocks", posBlockInfos));
167 if (fHelp || params.
size() != 0)
168 throw std::runtime_error(
170 "\nReturns the current supply.\n"
172 "n (numeric) The current supply\n"
182 if (fHelp || params.
size() != 0)
183 throw std::runtime_error(
185 "\nReturns the max supply.\n"
187 "n (numeric) The maximum supply\n"
196 if (fHelp || params.
size() != 0)
197 throw std::runtime_error(
199 "\nReturns the number of blocks in the longest block chain.\n"
201 "n (numeric) The current block count\n"
211 if (fHelp || params.
size() != 0)
212 throw std::runtime_error(
214 "\nReturns the hash of the best (tip) block in the longest block chain.\n"
216 "\"hex\" (string) the block hash hex encoded\n"
227 std::lock_guard<std::mutex> lock(cs_blockchange);
231 cond_blockchange.notify_all();
236 if (fHelp || params.
size() > 1)
237 throw std::runtime_error(
238 "waitfornewblock ( timeout )\n"
239 "\nWaits for a specific new block and returns useful info about it.\n"
240 "\nReturns the current block on timeout or exit.\n"
243 "1. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n"
247 " \"hash\" : { (string) The blockhash\n"
248 " \"height\" : { (int) Block height\n"
256 if (params.
size() > 0)
260 std::unique_lock<std::mutex> lock(cs_blockchange);
263 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&block]{
return latestblock.
height != block.
height || latestblock.
hash != block.
hash || !
IsRPCRunning(); });
276 if (fHelp || params.
size() < 1 || params.
size() > 2)
277 throw std::runtime_error(
278 "waitforblock blockhash ( timeout )\n"
279 "\nWaits for a specific new block and returns useful info about it.\n"
280 "\nReturns the current block on timeout or exit.\n"
283 "1. \"blockhash\" (required, std::string) Block hash to wait for.\n"
284 "2. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n"
288 " \"hash\" : { (string) The blockhash\n"
289 " \"height\" : { (int) Block height\n"
293 +
HelpExampleCli(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
294 +
HelpExampleRpc(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
300 if (params.
size() > 1)
305 std::unique_lock<std::mutex> lock(cs_blockchange);
307 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&hash]{
return latestblock.
hash == hash || !
IsRPCRunning();});
309 cond_blockchange.wait(lock, [&hash]{
return latestblock.
hash == hash || !
IsRPCRunning(); });
321 if (fHelp || params.
size() < 1 || params.
size() > 2)
322 throw std::runtime_error(
323 "waitforblockheight height ( timeout )\n"
324 "\nWaits for (at least) block height and returns the height and hash\n"
325 "of the current tip.\n"
326 "\nReturns the current block on timeout or exit.\n"
329 "1. height (required, int) Block height to wait for (int)\n"
330 "2. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n"
334 " \"hash\" : { (string) The blockhash\n"
335 " \"height\" : { (int) Block height\n"
344 int height = params[0].
get_int();
346 if (params.
size() > 1)
351 std::unique_lock<std::mutex> lock(cs_blockchange);
353 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&height]{
return latestblock.
height >= height || !
IsRPCRunning();});
355 cond_blockchange.wait(lock, [&height]{
return latestblock.
height >= height || !
IsRPCRunning(); });
366 if (fHelp || params.
size() != 0)
367 throw std::runtime_error(
369 "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
371 "n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
386 const uint256& hash = entry.first;
396 std::set<std::string> setDepends;
403 for (
const std::string& dep : setDepends) {
407 info.
push_back(Pair(
"depends", depends));
412 std::vector<uint256> vtxid;
416 for (
const uint256& hash : vtxid)
425 if (fHelp || params.
size() > 1)
426 throw std::runtime_error(
427 "getrawmempool ( verbose )\n"
428 "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
430 "1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
431 "\nResult: (for verbose = false):\n"
432 "[ (json array of string)\n"
433 " \"transactionid\" (string) The transaction id\n"
436 "\nResult: (for verbose = true):\n"
438 " \"transactionid\" : { (json object)\n"
439 " \"size\" : n, (numeric) transaction size in bytes\n"
440 " \"fee\" : n, (numeric) transaction fee in PRCY\n"
441 " \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
442 " \"height\" : n, (numeric) block height when transaction entered pool\n"
443 " \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
444 " \"currentpriority\" : n, (numeric) transaction priority now\n"
445 " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
446 " \"transactionid\", (string) parent transaction id\n"
455 bool fVerbose =
false;
456 if (params.
size() > 0)
465 if (fHelp || params.
size() != 1)
466 throw std::runtime_error(
467 "getblockhash index\n"
468 "\nReturns hash of block in best-block-chain at index provided.\n"
470 "1. index (numeric, required) The block index\n"
472 "\"hash\" (string) The block hash\n"
478 int nHeight = params[0].
get_int();
488 if (fHelp || params.
size() < 1 || params.
size() > 2)
489 throw std::runtime_error(
490 "getblock \"hash\" ( verbose )\n"
491 "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
492 "If verbose is true, returns an Object with information about block <hash>.\n"
494 "1. \"hash\" (string, required) The block hash\n"
495 "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
496 "\nResult (for verbose = true):\n"
498 " \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
499 " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
500 " \"size\" : n, (numeric) The block size\n"
501 " \"height\" : n, (numeric) The block height or index\n"
502 " \"version\" : n, (numeric) The block version\n"
503 " \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
504 " \"tx\" : [ (array of string) The transaction ids\n"
505 " \"transactionid\" (string) The transaction id\n"
508 " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
509 " \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n"
510 " \"nonce\" : n, (numeric) The nonce\n"
511 " \"bits\" : \"1d00ffff\", (string) The bits\n"
512 " \"difficulty\" : x.xxx, (numeric) The difficulty\n"
513 " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
514 " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
515 " \"moneysupply\" : \"supply\" (numeric) The money supply when this block was added to the blockchain\n"
517 "\nResult (for verbose=false):\n"
518 "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
520 HelpExampleCli(
"getblock",
"\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"") +
HelpExampleRpc(
"getblock",
"\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\""));
522 std::string strHash = params[0].
get_str();
525 bool fVerbose =
true;
526 if (params.
size() > 1)
550 if (fHelp || params.
size() < 1 || params.
size() > 2)
551 throw std::runtime_error(
552 "getblockheader \"hash\" ( verbose )\n"
553 "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash' header.\n"
554 "If verbose is true, returns an Object with information about block <hash> header.\n"
556 "1. \"hash\" (string, required) The block hash\n"
557 "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
558 "\nResult (for verbose = true):\n"
560 " \"version\" : n, (numeric) The block version\n"
561 " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
562 " \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
563 " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
564 " \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n"
565 " \"nonce\" : n, (numeric) The nonce\n"
566 " \"bits\" : \"1d00ffff\", (string) The bits\n"
568 "\nResult (for verbose=false):\n"
569 "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash' header.\n"
571 HelpExampleCli(
"getblockheader",
"\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"") +
HelpExampleRpc(
"getblockheader",
"\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\""));
573 std::string strHash = params[0].
get_str();
576 bool fVerbose =
true;
577 if (params.
size() > 1)
601 if (fHelp || params.
size() != 0)
602 throw std::runtime_error(
604 "\nReturns statistics about the unspent transaction output set.\n"
605 "Note this call may take some time.\n"
608 " \"height\":n, (numeric) The current block height (index)\n"
609 " \"bestblock\": \"hex\", (string) the best block hash hex\n"
610 " \"transactions\": n, (numeric) The number of transactions\n"
611 " \"txouts\": n, (numeric) The number of output transactions\n"
612 " \"bytes_serialized\": n, (numeric) The serialized size\n"
613 " \"hash_serialized\": \"hash\", (string) The serialized hash\n"
614 " \"total_amount\": x.xxx (numeric) The total amount\n"
637 if (fHelp || params.
size() < 2 || params.
size() > 3)
638 throw std::runtime_error(
639 "gettxout \"txid\" n ( includemempool )\n"
640 "\nReturns details about an unspent transaction output.\n"
642 "1. \"txid\" (string, required) The transaction id\n"
643 "2. n (numeric, required) vout value\n"
644 "3. includemempool (boolean, optional) Whether to included the mem pool\n"
647 " \"bestblock\" : \"hash\", (string) the block hash\n"
648 " \"confirmations\" : n, (numeric) The number of confirmations\n"
649 " \"value\" : x.xxx, (numeric) The transaction value in PRCY\n"
650 " \"scriptPubKey\" : { (json object)\n"
651 " \"asm\" : \"code\", (string) \n"
652 " \"hex\" : \"hex\", (string) \n"
653 " \"reqSigs\" : n, (numeric) Number of required signatures\n"
654 " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n"
655 " \"addresses\" : [ (array of string) array of prcycoin addresses\n"
656 " \"prcycoinaddress\" (string) prcycoin address\n"
660 " \"version\" : n, (numeric) The version\n"
661 " \"coinbase\" : true|false (boolean) Coinbase or not\n"
665 "\nGet unspent transactions\n" +
667 "\nView the details\n" +
HelpExampleCli(
"gettxout",
"\"txid\" 1") +
668 "\nAs a json rpc call\n" +
HelpExampleRpc(
"gettxout",
"\"txid\", 1"));
674 std::string strHash = params[0].
get_str();
677 bool fMempool =
true;
678 if (params.
size() > 2)
692 if (n < 0 || (
unsigned int)n >= coins.
vout.size() || coins.
vout[n].IsNull())
698 if ((
unsigned int)coins.
nHeight == MEMPOOL_HEIGHT)
714 if (fHelp || params.
size() > 1)
715 throw std::runtime_error(
716 "verifychain ( numblocks )\n"
717 "\nVerifies blockchain database.\n"
719 "1. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
721 "true|false (boolean) Verified or not\n"
728 int nCheckDepth =
GetArg(
"-checkblocks", 288);
729 if (params.
size() > 0)
730 nCheckDepth = params[0].
get_int();
748 pstart = pstart->
pprev;
751 rv.push_back(Pair(
"status", nFound >= nRequired));
752 rv.push_back(Pair(
"found", nFound));
753 rv.push_back(Pair(
"required", nRequired));
754 rv.push_back(Pair(
"window",
Params().ToCheckBlockUpgradeMajority()));
760 rv.push_back(Pair(
"id",
name));
761 rv.push_back(Pair(
"version", version));
762 rv.push_back(Pair(
"enforce", SoftForkMajorityDesc(version, pindex,
Params().EnforceBlockUpgradeMajority())));
763 rv.push_back(Pair(
"reject", SoftForkMajorityDesc(version, pindex,
Params().RejectBlockOutdatedMajority())));
769 if (fHelp || params.
size() != 0)
770 throw std::runtime_error(
771 "getblockchaininfo\n"
772 "Returns an object containing various state info regarding block chain processing.\n"
775 " \"chain\": \"xxxx\", (string) current network name (main, test, regtest)\n"
776 " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
777 " \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n"
778 " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
779 " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
780 " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
781 " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
782 " \"softforks\": [ (array) status of softforks in progress\n"
784 " \"id\": \"xxxx\", (string) name of softfork\n"
785 " \"version\": xx, (numeric) block version\n"
786 " \"enforce\": { (object) progress toward enforcing the softfork rules for new-version blocks\n"
787 " \"status\": xx, (boolean) true if threshold reached\n"
788 " \"found\": xx, (numeric) number of blocks with the new version found\n"
789 " \"required\": xx, (numeric) number of blocks required to trigger\n"
790 " \"window\": xx, (numeric) maximum size of examined window of recent blocks\n"
792 " \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
811 softforks.
push_back(SoftForkDesc(
"bip65", 5, tip));
812 obj.
push_back(Pair(
"softforks", softforks));
832 if (fHelp || params.
size() != 0)
833 throw std::runtime_error(
835 "Return information about all known tips in the block tree,"
836 " including the main chain as well as orphaned branches.\n"
840 " \"height\": xxxx, (numeric) height of the chain tip\n"
841 " \"hash\": \"xxxx\", (string) block hash of the tip\n"
842 " \"branchlen\": 0 (numeric) zero for main chain\n"
843 " \"status\": \"active\" (string) \"active\" for the main chain\n"
846 " \"height\": xxxx,\n"
847 " \"hash\": \"xxxx\",\n"
848 " \"branchlen\": 1 (numeric) length of branch connecting the tip to the main chain\n"
849 " \"status\": \"xxxx\" (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)\n"
852 "Possible values for status:\n"
853 "1. \"invalid\" This branch contains at least one invalid block\n"
854 "2. \"headers-only\" Not all blocks for this branch are available, but the headers are valid\n"
855 "3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n"
856 "4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n"
857 "5. \"active\" This is the tip of the active main chain, which is certainly valid\n"
866 std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
869 setTips.insert(item.second);
874 setTips.erase(pprev);
885 obj.
push_back(Pair(
"height", block->nHeight));
886 obj.
push_back(Pair(
"hash", block->phashBlock->GetHex()));
889 obj.
push_back(Pair(
"branchlen", branchLen));
898 }
else if (block->nChainTx == 0) {
900 status =
"headers-only";
903 status =
"valid-fork";
906 status =
"valid-headers";
921 if (fHelp || params.
size() != 1)
922 throw std::runtime_error(
923 "getfeeinfo blocks\n"
924 "\nReturns details of transaction fees over the last n blocks.\n"
927 "1. blocks (int, required) the number of blocks to get transaction data from\n"
931 " \"txcount\": xxxxx (numeric) Current tx count\n"
932 " \"txbytes\": xxxxx (numeric) Sum of all tx sizes\n"
933 " \"ttlfee\": xxxxx (numeric) Sum of all fees\n"
934 " \"feeperkb\": xxxxx (numeric) Average fee per kb over the block range\n"
935 " \"rec_highpriorityfee_perkb\": xxxxx (numeric) Recommended fee per kb to use for a high priority tx\n"
941 int nBlocks = params[0].
get_int();
947 int nStartHeight = nBestHeight - nBlocks;
948 if (nBlocks < 0 || nStartHeight <= 0)
971 if (fHelp || params.
size() != 0)
972 throw std::runtime_error(
974 "\nReturns details on the active state of the TX memory pool.\n"
977 " \"size\": xxxxx (numeric) Current tx count\n"
978 " \"bytes\": xxxxx (numeric) Sum of all tx sizes\n"
988 if (fHelp || params.
size() != 1)
989 throw std::runtime_error(
990 "invalidateblock \"hash\"\n"
991 "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
993 "1. hash (string, required) the hash of the block to mark as invalid\n"
998 std::string strHash = params[0].
get_str();
1024 if (fHelp || params.
size() != 1)
1025 throw std::runtime_error(
1026 "resyncfrom \"block height\"\n"
1027 "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
1029 "1. height (numeric, required) the hash of the block to mark as invalid\n"
1034 int height = params[0].
get_int();
1059 if (fHelp || params.
size() != 1)
1060 throw std::runtime_error(
1061 "reconsiderblock \"hash\"\n"
1062 "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
1063 "This can be used to undo the effects of invalidateblock.\n"
1065 "1. hash (string, required) the hash of the block to reconsider\n"
1070 std::string strHash = params[0].
get_str();
1096 if (fHelp || params.
size() > 1)
1097 throw std::runtime_error(
1099 "\nGet a summary of invalidated outpoints.\n"
1101 "1. all (string, optional) return a full list of outpoints even if they are spent\n"
1105 std::string strCommand;
1106 if (params.
size() == 1){
1107 strCommand = params[0].
get_str();
1110 bool fShowAll =
false;
1111 if (strCommand ==
"all")
1117 std::map<CBitcoinAddress, CAmount> mapBanAddress;
1118 std::map<COutPoint, int> mapMixedValid;
1131 objTx.
push_back(Pair(
"inv_out", it.first.ToString()));
1155 nMixedValid += nValid;
1156 mapMixedValid[in2.
prevout] = 1;
1160 bool fSpent =
false;
1167 if (!objMixedValid.
empty())
1168 objTx.
push_back(Pair(
"mixed_with_valid", objMixedValid));
1177 mapBanAddress[address] += nValue;
1181 if (fSpent && !fShowAll)
1188 for (
auto it : mapBanAddress)
1192 obj.
push_back(Pair(
"addresses_with_invalid", objAddresses));
1203 if (fHelp || params.
size() != 1)
1204 throw std::runtime_error(
1205 "setmaxreorgdepth <value>\n"
1206 "\nSet max reorganization depth to a value.\n"
1208 "1. num (numeric, required) the number of blocks\n"
1213 int num = params[0].
get_int();
1215 throw std::runtime_error(
"Invalid number");
1226 if (fHelp || params.
size() != 0)
1227 throw std::runtime_error(
1229 "\nReturns all details of the last PoA block\n"
1231 "\"hash\" (string) The last PoA block hash\n"
1244 pindex = pindex->
pprev;
1253 if (fHelp || params.
size() != 0)
1254 throw std::runtime_error(
1255 "getlastpoablockhash\n"
1256 "\nReturns hash of the last PoA block.\n"
1258 "\"hash\" (string) The last PoA block hash\n"
1270 pindex = pindex->
pprev;
1278 if (fHelp || params.
size() != 0)
1279 throw std::runtime_error(
1280 "getlastpoablockheight\n"
1281 "\nReturns block height of the last PoA block.\n"
1283 "\"height\" (numeric) The last PoA block height\n"
1295 pindex = pindex->
pprev;
1303 if (fHelp || params.
size() != 0)
1304 throw std::runtime_error(
1305 "getlastpoablocktime\n"
1306 "\nReturns the time in seconds since epoch (Jan 1 1970 GMT) of the last PoA block.\n"
1308 "\"time\" (numeric) The last PoA block time in seconds since epoch (Jan 1 1970 GMT)\n"
1320 pindex = pindex->
pprev;
1323 int nTime = pindex->
nTime;
1330 if (fHelp || params.
size() != 0)
1331 throw std::runtime_error(
1332 "getlastpoaauditedpos\n"
1333 "\nReturns the last audited PoS block in the last PoA block.\n"
1335 "\"height\" (numeric) The last audited PoS block in the last PoA block\n"
1341 int lastPoSHeight = 0;
1349 pindex = pindex->
pprev;
1356 return lastPoSHeight;
1361 if (params.
size() < 2) {
1371 heightStart = params[0].
get_int();
1372 if (heightStart > nBestHeight) {
1376 const int range = params[1].
get_int();
1381 heightEnd = heightStart + range - 1;
1383 if (heightStart < minHeightStart && heightEnd >= minHeightStart) {
1384 heightStart = minHeightStart;
1387 if (heightEnd > nBestHeight) {
1393 if (fHelp || params.
size() < 2 || params.
size() > 3)
1394 throw std::runtime_error(
1395 "getblockindexstats height range ( fFeeOnly )\n"
1396 "\nReturns aggregated BlockIndex data for blocks "
1397 "\n[height, height+1, height+2, ..., height+range-1]\n"
1400 "1. height (numeric, required) block height where the search starts.\n"
1401 "2. range (numeric, required) number of blocks to include.\n"
1402 "3. fFeeOnly (boolean, optional, default=False) return only fee info.\n"
1406 " \"first_block\": \"x\" (integer) First counted block\n"
1407 " \"last_block\": \"x\" (integer) Last counted block\n"
1408 " \"txcount\": xxxxx (numeric) tx count (excluding coinbase/coinstake)\n"
1409 " \"txcount_all\": xxxxx (numeric) tx count (including coinbase/coinstake)\n"
1411 " \"txbytes\": xxxxx (numeric) Sum of the size of all txes over block range\n"
1412 " \"ttlfee\": xxxxx (numeric) Sum of the fee amount of all txes over block range\n"
1413 " \"ttlfee_all\": xxxxx (numeric) Sum of the fee amount of all txes over block range\n"
1414 " \"feeperkb\": xxxxx (numeric) Average fee per kb\n"
1421 int heightStart, heightEnd;
1425 ret.
push_back(Pair(
"Starting block", heightStart));
1426 ret.
push_back(Pair(
"Ending block", heightEnd));
1428 bool fFeeOnly =
false;
1429 if (params.
size() > 2) {
1436 int64_t nTxCount = 0;
1437 int64_t nTxCount_all = 0;
1456 const int ntx = block.
vtx.size();
1457 nTxCount_all += ntx;
1458 nTxCount = block.
IsProofOfStake() ? nTxCount + ntx - 2 : nTxCount + ntx - 1;
1466 for (
unsigned int j = 0; j < tx.
vin.size(); j++) {
1472 nValueIn += txPrev.
vout[prevout.
n].nValue;
1476 for (
unsigned int j = 0; j < tx.
vout.size(); j++) {
1477 nValueOut += tx.
vout[j].nValue;
1483 nBytes += tx.GetSerializeSize(
SER_NETWORK, CLIENT_VERSION);
1486 if (pindex->
nHeight < heightEnd) {
1498 ret.
push_back(Pair(
"txcount", (int64_t)nTxCount));
1499 ret.
push_back(Pair(
"txcount_all", (int64_t)nTxCount_all));
1500 ret.
push_back(Pair(
"txbytes", (int64_t)nBytes));
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
UniValue mempoolInfoToJSON()
An input of a transaction.
UniValue getblockindexstats(const UniValue ¶ms, bool fHelp)
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
const uint256 UINT256_ZERO
constant uint256 instances
UniValue invalidateblock(const UniValue ¶ms, bool fHelp)
UniValue getblockcount(const UniValue ¶ms, bool fHelp)
UniValue mempoolToJSON(bool fVerbose=false)
bool IsProofOfStake() const
void pruneSpent(const uint256 &hash, CCoins &coins)
UniValue getbestblockhash(const UniValue ¶ms, bool fHelp)
UniValue getlastpoaauditedpos(const UniValue ¶ms, bool fHelp)
unsigned int GetHeight() const
UniValue getlastpoablock(const UniValue ¶ms, bool fHelp)
UniValue getmaxsupply(const UniValue ¶ms, bool fHelp)
UniValue getrawmempool(const UniValue ¶ms, bool fHelp)
UniValue getchaintips(const UniValue ¶ms, bool fHelp)
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
UniValue gettxout(const UniValue ¶ms, bool fHelp)
const_iterator begin() const
bool GetStats(CCoinsStats &stats) const
Calculate statistics about the unspent transaction output set.
std::string GetHex() const
void validaterange(const UniValue ¶ms, int &heightStart, int &heightEnd, int minHeightStart)
UniValue ValueFromAmount(const CAmount &amount)
UniValue getblock(const UniValue ¶ms, bool fHelp)
CChain chainActive
The currently-connected chain of blocks.
@ BLOCK_FAILED_MASK
descends from failed block
const UniValue NullUniValue
UniValue getlastpoablocktime(const UniValue ¶ms, bool fHelp)
base58-encoded PRCY addresses.
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
bool exists(uint256 hash)
CBlockIndex * pprev
pointer to the index of the predecessor of this block
bool IsAvailable(unsigned int nPos) const
check whether a particular output is still available
int nHeight
height of the entry in the chain. The genesis block has height 0
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
Comparison function for sorting the getchaintips heads.
uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
unsigned int GetSerializeSize(char a, int, int=0)
int nHeight
at which height this transaction was included in the active block chain
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
bool InvalidateBlock(CValidationState &state, CBlockIndex *pindex)
Mark a block as invalid.
std::string GetRejectReason() const
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
UniValue getmempoolinfo(const UniValue ¶ms, bool fHelp)
Fee rate in PRCY per kilobyte: CAmount / kB.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
The basic transaction that is broadcasted on the network and contained in blocks.
bool ActivateBestChain(CValidationState &state, CBlock *pblock, bool fAlreadyChecked)
Make the best chain active, in multiple steps.
void PoSBlockInfoToJSON(const uint256 hashBlock, int64_t nTime, int height, UniValue &entry)
const std::string & get_str() const
RecursiveMutex cs_main
Global state.
CBlockHeader GetBlockHeader() const
std::vector< CTxOut > vout
unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are d...
UniValue reconsiderblock(const UniValue ¶ms, bool fHelp)
UniValue blockheaderToJSON(const CBlockIndex *blockindex)
RecursiveMutex cs
sum of all mempool tx' byte sizes
UniValue getblockchaininfo(const UniValue ¶ms, bool fHelp)
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock.
double GetDifficulty(const CBlockIndex *blockindex)
int64_t GetMedianTimePast() const
std::vector< CTxOut > vout
UniValue resyncfrom(const UniValue ¶ms, bool fHelp)
@ RPC_DATABASE_ERROR
Invalid, missing or duplicate parameter.
const_iterator end() const
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
#define PAIRTYPE(t1, t2)
This is needed because the foreach macro can't get over the comma in pair<t1, t2>
UniValue JSONRPCError(int code, const std::string &message)
int64_t CAmount
Amount in PRCY (Can be negative)
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
UniValue waitfornewblock(const UniValue ¶ms, bool fHelp)
UniValue waitforblockheight(const UniValue ¶ms, bool fHelp)
CTxMemPool mempool(::minRelayTxFee)
uint64_t GetTotalTxSize()
std::string HelpExampleRpc(std::string methodname, std::string args)
256-bit unsigned big integer.
uint256 uint256S(const char *str)
Serialized script, used inside transaction inputs and outputs.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
uint256 GetBlockHash() const
const CCoins * AccessCoins(const uint256 &txid) const
Return a pointer to CCoins in the cache, or NULL if not found.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
int Height() const
Return the maximal height in the chain.
UniValue getblockhash(const UniValue ¶ms, bool fHelp)
UniValue getlastpoablockhash(const UniValue ¶ms, bool fHelp)
uint256 nAccumulatorCheckpoint
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
std::string HelpExampleCli(std::string methodname, std::string args)
void RPCNotifyBlockChange(bool fInitialDownload, const CBlockIndex *pindex)
@ RPC_INVALID_ADDRESS_OR_KEY
Unexpected type was passed as parameter.
std::vector< CTransaction > vtx
int nVersion
version of the CTransaction; accesses to this value should probably check for nHeight as well,...
UniValue getlastpoablockheight(const UniValue ¶ms, bool fHelp)
UniValue verifychain(const UniValue ¶ms, bool fHelp)
void ScriptPubKeyToJSON(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
void queryHashes(std::vector< uint256 > &vtxid)
double GuessVerificationProgress(const CBlockIndex *pindex, bool fSigchecks)
Guess how far we are in the verification process at the given block index.
bool VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
void ChangeMaxReorg(int num) const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
uint64_t nTransactionOutputs
bool operator()(const CBlockIndex *a, const CBlockIndex *b) const
UniValue setmaxreorgdepth(const UniValue ¶ms, bool fHelp)
std::map< uint256, CTxMemPoolEntry > mapTx
double GetPriority(unsigned int currentHeight) const
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
CCoinsView that brings transactions from a memorypool into view.
bool push_back(const UniValue &val)
const CChainParams & Params()
Return the currently selected parameters.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
std::map< COutPoint, COutPoint > mapInvalidOutPoints
Double ended buffer combining vector and stream-like interfaces.
bool fCoinBase
whether transaction is a coinbase
std::string ToString() const
const uint256 & GetHash() const
uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
UniValue getsupply(const UniValue ¶ms, bool fHelp)
An outpoint - a combination of a transaction hash and an index n into its vout.
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
bool IsProofOfAudit() const
UniValue gettxoutsetinfo(const UniValue ¶ms, bool fHelp)
UniValue waitforblock(const UniValue ¶ms, bool fHelp)
The block chain is a tree shaped structure starting with the genesis block at the root,...
CAmount GetFeePerK() const
void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Capture information about block/transaction validation.
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
CBlockIndex * Next(const CBlockIndex *pindex) const
Find the successor of a block in this chain, or NULL if the given index is not found or is the tip.
bool IsProofOfStake() const
UniValue getblockheader(const UniValue ¶ms, bool fHelp)
UniValue blockToJSON(const CBlock &block, const CBlockIndex *blockindex, bool txDetails=false)
UniValue getinvalid(const UniValue ¶ms, bool fHelp)
UniValue getdifficulty(const UniValue ¶ms, bool fHelp)
std::vector< PoSBlockSummary > posBlocksAudited
int ToCheckBlockUpgradeMajority() const
UniValue getfeeinfo(const UniValue ¶ms, bool fHelp)
const CTransaction & GetTx() const
std::string ToString() const