36 #include <boost/thread/thread.hpp> 39 #include <condition_variable> 51 if (blockindex ==
nullptr)
59 uint32_t bits = blockindex->
nBits;
63 int nShift = (bits >> 24) & 0xff;
64 int nShiftAmount = (powLimit >> 24) & 0xff;
67 (double)(powLimit & 0x00ffffff) /
68 (double)(bits & 0x00ffffff);
70 while (nShift < nShiftAmount)
75 while (nShift > nShiftAmount)
86 int nShift = (blockindex->
nBits >> 24) & 0xff;
89 (double)0x0000ffff / (
double)(blockindex->
nBits & 0x00ffffff);
107 if (blockindex ==
nullptr)
115 if ((uint32_t) blockindex->
nHeight >=
Params().GetConsensus().FABHeight)
130 int confirmations = -1;
145 if ( contract_format ) {
153 if ( legacy_format ){
165 if (blockindex->
pprev)
179 int confirmations = -1;
188 PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS )));
190 result.
push_back(
Pair(
"weight", (
int)::GetBlockWeight(block, consensusParams)));
198 if ( contract_format ) {
203 for(
const auto& tx : block.
vtx)
226 if (blockindex->
pprev)
238 std::stringstream ss;
277 throw std::runtime_error(
279 "\nReturns the number of blocks in the longest blockchain.\n" 281 "n (numeric) The current block count\n" 294 throw std::runtime_error(
296 "\nReturns the hash of the best (tip) block in the longest blockchain.\n" 298 "\"hex\" (string) the block hash hex encoded\n" 311 std::lock_guard<std::mutex> lock(cs_blockchange);
313 latestblock.height = pindex->
nHeight;
315 cond_blockchange.notify_all();
321 throw std::runtime_error(
322 "waitfornewblock (timeout)\n" 323 "\nWaits for a specific new block and returns useful info about it.\n" 324 "\nReturns the current block on timeout or exit.\n" 326 "1. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n" 329 " \"hash\" : { (string) The blockhash\n" 330 " \"height\" : { (int) Block height\n" 342 std::unique_lock<std::mutex> lock(cs_blockchange);
345 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&block]{
return latestblock.height != block.
height || latestblock.hash != block.
hash || !
IsRPCRunning(); });
347 cond_blockchange.wait(lock, [&block]{
return latestblock.height != block.
height || latestblock.hash != block.
hash || !
IsRPCRunning(); });
359 throw std::runtime_error(
360 "waitforblock <blockhash> (timeout)\n" 361 "\nWaits for a specific new block and returns useful info about it.\n" 362 "\nReturns the current block on timeout or exit.\n" 364 "1. \"blockhash\" (required, string) Block hash to wait for.\n" 365 "2. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n" 368 " \"hash\" : { (string) The blockhash\n" 369 " \"height\" : { (int) Block height\n" 372 +
HelpExampleCli(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
373 +
HelpExampleRpc(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
384 std::unique_lock<std::mutex> lock(cs_blockchange);
386 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&hash]{
return latestblock.hash == hash || !
IsRPCRunning();});
388 cond_blockchange.wait(lock, [&hash]{
return latestblock.hash == hash || !
IsRPCRunning(); });
401 throw std::runtime_error(
402 "waitforblockheight <height> (timeout)\n" 403 "\nWaits for (at least) block height and returns the height and hash\n" 404 "of the current tip.\n" 405 "\nReturns the current block on timeout or exit.\n" 407 "1. height (required, int) Block height to wait for (int)\n" 408 "2. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n" 411 " \"hash\" : { (string) The blockhash\n" 412 " \"height\" : { (int) Block height\n" 427 std::unique_lock<std::mutex> lock(cs_blockchange);
429 cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&height]{
return latestblock.height >= height || !
IsRPCRunning();});
431 cond_blockchange.wait(lock, [&height]{
return latestblock.height >= height || !
IsRPCRunning(); });
443 throw std::runtime_error(
445 "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n" 447 "n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n" 459 return " \"size\" : n, (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.\n" 460 " \"fee\" : n, (numeric) transaction fee in " +
CURRENCY_UNIT +
"\n" 461 " \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n" 462 " \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n" 463 " \"height\" : n, (numeric) block height when transaction entered pool\n" 464 " \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n" 465 " \"descendantsize\" : n, (numeric) virtual transaction size of in-mempool descendants (including this one)\n" 466 " \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n" 467 " \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n" 468 " \"ancestorsize\" : n, (numeric) virtual transaction size of in-mempool ancestors (including this one)\n" 469 " \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n" 470 " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n" 471 " \"transactionid\", (string) parent transaction id\n" 491 std::set<std::string> setDepends;
499 for (
const std::string& dep : setDepends)
524 std::vector<uint256> vtxid;
528 for (
const uint256& hash : vtxid)
538 throw std::runtime_error(
539 "getrawmempool ( verbose )\n" 540 "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n" 541 "\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n" 543 "1. verbose (boolean, optional, default=false) True for a json object, false for array of transaction ids\n" 544 "\nResult: (for verbose = false):\n" 545 "[ (json array of string)\n" 546 " \"transactionid\" (string) The transaction id\n" 549 "\nResult: (for verbose = true):\n" 551 " \"transactionid\" : { (json object)\n" 560 bool fVerbose =
false;
570 throw std::runtime_error(
571 "getmempoolancestors txid (verbose)\n" 572 "\nIf txid is in the mempool, returns all in-mempool ancestors.\n" 574 "1. \"txid\" (string, required) The transaction id (must be in mempool)\n" 575 "2. verbose (boolean, optional, default=false) True for a json object, false for array of transaction ids\n" 576 "\nResult (for verbose=false):\n" 577 "[ (json array of strings)\n" 578 " \"transactionid\" (string) The transaction id of an in-mempool ancestor transaction\n" 581 "\nResult (for verbose=true):\n" 583 " \"transactionid\" : { (json object)\n" 593 bool fVerbose =
false;
614 o.
push_back(ancestorIt->GetTx().GetHash().ToString());
634 throw std::runtime_error(
635 "getmempooldescendants txid (verbose)\n" 636 "\nIf txid is in the mempool, returns all in-mempool descendants.\n" 638 "1. \"txid\" (string, required) The transaction id (must be in mempool)\n" 639 "2. verbose (boolean, optional, default=false) True for a json object, false for array of transaction ids\n" 640 "\nResult (for verbose=false):\n" 641 "[ (json array of strings)\n" 642 " \"transactionid\" (string) The transaction id of an in-mempool descendant transaction\n" 645 "\nResult (for verbose=true):\n" 647 " \"transactionid\" : { (json object)\n" 657 bool fVerbose =
false;
673 setDescendants.erase(it);
678 o.
push_back(descendantIt->GetTx().GetHash().ToString());
698 throw std::runtime_error(
699 "getmempoolentry txid\n" 700 "\nReturns mempool data for given transaction\n" 702 "1. \"txid\" (string, required) The transaction id (must be in mempool)\n" 731 throw std::runtime_error(
732 "getblockhash height\n" 733 "\nReturns hash of block in best-block-chain at height provided.\n" 735 "1. height (numeric, required) The height index\n" 737 "\"hash\" (string) The block hash\n" 756 throw std::runtime_error(
757 "getaccountinfo \"address\"\n" 759 "1. \"address\" (string, required) The account address\n" 765 if(strAddr.size() != 40 || !
CheckHex(strAddr))
780 for (
auto j: storage)
784 storageUV.push_back(
Pair(j.first.hex(),
e));
791 std::unordered_map<dev::Address, Vin> vins =
globalState->vins();
792 if(vins.count(addrAccount)){
794 valtype vchHash(vins[addrAccount].hash.asBytes());
796 vin.
push_back(
Pair(
"nVout", uint64_t(vins[addrAccount].nVout)));
797 vin.
push_back(
Pair(
"value", uint64_t(vins[addrAccount].value)));
806 throw std::runtime_error(
807 "getstorage \"address\"\n" 809 "1. \"address\" (string, required) The address to get the storage from\n" 810 "2. \"blockNum\" (string, optional) Number of block to get state from, \"latest\" keyword supported. Latest if not passed.\n" 811 "3. \"index\" (number, optional) Zero-based index position of the storage\n" 817 if(strAddr.size() != 40 || !
CheckHex(strAddr))
852 if (index >= storage.size())
854 std::ostringstream stringStream;
855 stringStream <<
"Storage size: " << storage.size() <<
" got index: " << index;
858 auto elem = std::next(storage.begin(), index);
861 storage = {{elem->first, {elem->second.first, elem->second.second}}};
863 for (
const auto& j: storage)
874 throw std::runtime_error(
875 "getblockheader \"hash\" ( verbose legacy no_contract)\n" 876 "\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n" 877 "If verbose is true, returns an Object with information about blockheader <hash>.\n" 879 "1. \"hash\" (string, required) The block hash\n" 880 "2. \"verbose\" (boolean, optional, default=true) true for a json object, false for the hex encoded data\n" 881 "3. \"legacy \" (boolean, optional, default=false) indicates if the block should be in legacy format\n" 882 "4. \"no_contract\" (boolean, optional, default=false) indicates if the block should be in non-contract format\n" 883 "\nResult (for verbose = true):\n" 885 " \"hash\" : \"hash\", (string) the block hash (same as provided)\n" 886 " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" 887 " \"height\" : n, (numeric) The block height or index\n" 888 " \"version\" : n, (numeric) The block version\n" 889 " \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n" 890 " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" 891 " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" 892 " \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n" 893 " \"nonce\" : n, (numeric) The nonce\n" 894 " \"bits\" : \"1d00ffff\", (string) The bits\n" 895 " \"difficulty\" : x.xxx, (numeric) The difficulty\n" 896 " \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n" 897 " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" 898 " \"nextblockhash\" : \"hash\", (string) The hash of the next block\n" 900 "\nResult (for verbose=false):\n" 901 "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" 903 +
HelpExampleCli(
"getblockheader",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
904 +
HelpExampleRpc(
"getblockheader",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
912 bool fVerbose =
true;
936 throw std::runtime_error(
937 "getblock \"blockhash\" ( verbosity legacy no_contract) \n" 938 "\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n" 939 "If verbosity is 1, returns an Object with information about block <hash>.\n" 940 "If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n" 942 "1. \"blockhash\" (string, required) The block hash\n" 943 "2. \"verbosity\" (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data\n" 944 "3. \"legacy\" (boolean, optional, default=false) indicates if the block should be in legacy format\n" 945 "4. \"no_contract\" (boolean, optional, default=false) indicates if the block should be in non-contract format\n" 946 "\nResult (for verbosity = 0):\n" 947 "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" 948 "\nResult (for verbosity = 1):\n" 950 " \"hash\" : \"hash\", (string) the block hash (same as provided)\n" 951 " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" 952 " \"size\" : n, (numeric) The block size\n" 953 " \"strippedsize\" : n, (numeric) The block size excluding witness data\n" 954 " \"weight\" : n (numeric) The block weight as defined in BIP 141\n" 955 " \"height\" : n, (numeric) The block height or index\n" 956 " \"version\" : n, (numeric) The block version\n" 957 " \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n" 958 " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" 959 " \"tx\" : [ (array of string) The transaction ids\n" 960 " \"transactionid\" (string) The transaction id\n" 963 " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" 964 " \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n" 965 " \"nonce\" : n, (numeric) The nonce\n" 966 " \"bits\" : \"1d00ffff\", (string) The bits\n" 967 " \"difficulty\" : x.xxx, (numeric) The difficulty\n" 968 " \"chainwork\" : \"xxxx\", (string) Expected number of hashes required to produce the chain up to this block (in hex)\n" 969 " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" 970 " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" 972 "\nResult (for verbosity = 2):\n" 974 " ..., Same output as verbosity = 1.\n" 975 " \"tx\" : [ (array of Objects) The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result.\n" 978 " ,... Same output as verbosity = 1.\n" 981 +
HelpExampleCli(
"getblock",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
982 +
HelpExampleRpc(
"getblock",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
1025 return blockToJSON(block, pblockindex, verbosity >= 2);
1031 throw std::runtime_error(
1032 "callcontract \"address\" \"data\" ( address gasLimit )\n" 1034 "1. \"address\" (string, required) The account address\n" 1035 "2. \"data\" (string, required) The data hex string\n" 1036 "3. address (string, optional) The sender address hex string\n" 1037 "4. gasLimit (numeric, optional) The gas limit for executing the contract\n" 1048 if(data.size() % 2 != 0 || !
CheckHex(data))
1051 if(strAddr.size() != 40 || !
CheckHex(strAddr))
1061 if(fascSenderAddress.IsValid()){
1063 fascSenderAddress.GetKeyID(keyid);
1071 std::vector<ResultExecute> execResults =
CallContract(addrAccount,
ParseHex(data), senderAddress, gasLimit);
1097 std::stringstream ss;
1103 bool includeAddress) {
1104 if (includeAddress) {
1119 const auto& logs = resExec.
logs;
1121 for(
const auto&log : logs){
1144 auto blockKey = val.
get_str();
1146 if (blockKey ==
"latest") {
1147 return latestblock.height;
1154 int blockHeight = val.
get_int();
1156 if (blockHeight < 0) {
1157 return latestblock.height;
1181 if (addrStr.length() != 40 || !
CheckHex(addrStr)) {
1203 h160s.resize(vals.size());
1205 std::transform(vals.begin(), vals.end(), h160s.begin(), [](
UniValue val) ->
dev::h160 {
1211 std::vector<dev::h160> v;
1213 h160s.insert(v.begin(), v.end());
1226 h256s.resize(vals.size());
1228 std::transform(vals.begin(), vals.end(),
h256s.begin(), [](
UniValue val) -> boost::optional<dev::h256> {
1230 return boost::optional<dev::h256>();
1239 if (addrStr.length() != 64 || !
CheckHex(addrStr)) {
1243 return boost::optional<dev::h256>(
dev::h256(addrStr));
1255 std::vector<boost::optional<dev::h256>>
topics;
1260 std::unique_lock<std::mutex> lock(cs_blockchange);
1284 if (request.
fHelp) {
1285 throw std::runtime_error(
1286 "waitforlogs (fromBlock) (toBlock) (filter) (minconf)\n" 1287 "requires -logevents to be enabled\n" 1288 "\nWaits for a new logs and return matching log entries. When the call returns, it also specifies the next block number to start waiting for new logs.\n" 1289 "By calling waitforlogs repeatedly using the returned `nextBlock` number, a client can receive a stream of up-to-date log entires.\n" 1290 "\nThis call is different from the similarly named `waitforlogs`. This call returns individual matching log entries, `searchlogs` returns a transaction receipt if one of the log entries of that transaction matches the filter conditions.\n" 1292 "1. fromBlock (int | \"latest\", optional, default=null) The block number to start looking for logs. ()\n" 1293 "2. toBlock (int | \"latest\", optional, default=null) The block number to stop looking for logs. If null, will wait indefinitely into the future.\n" 1294 "3. filter ({ addresses?: Hex160String[], topics?: Hex256String[] }, optional default={}) Filter conditions for logs. Addresses and topics are specified as array of hexadecimal strings\n" 1295 "4. minconf (uint, optional, default=6) Minimal number of confirmations before a log is returned\n" 1297 "An object with the following properties:\n" 1298 "1. logs (LogEntry[]) Array of matchiing log entries. This may be empty if `filter` removed all entries." 1299 "2. count (int) How many log entries are returned." 1300 "3. nextBlock (int) To wait for new log entries haven't seen before, use this number as `fromBlock`" 1302 "`waitforlogs` waits for new logs, starting from the tip of the chain.\n" 1303 "`waitforlogs 600` waits for new logs, but starting from block 600. If there are logs available, this call will return immediately.\n" 1304 "`waitforlogs 600 700` waits for new logs, but only up to 700th block\n" 1305 "`waitforlogs null null` this is equivalent to `waitforlogs`, using default parameter values\n" 1306 "`waitforlogs null null` { \"addresses\": [ \"ff0011...\" ], \"topics\": [ \"c0fefe\"] }` waits for logs in the future matching the specified conditions\n" 1307 "\nSample Output:\n" 1308 "{\n \"entries\": [\n {\n \"blockHash\": \"56d5f1f5ec239ef9c822d9ed600fe9aa63727071770ac7c0eabfc903bf7316d4\",\n \"blockNumber\": 3286,\n \"transactionHash\": \"00aa0f041ce333bc3a855b2cba03c41427cda04f0334d7f6cb0acad62f338ddc\",\n \"transactionIndex\": 2,\n \"from\": \"3f6866e2b59121ada1ddfc8edc84a92d9655675f\",\n \"to\": \"8e1ee0b38b719abe8fa984c986eabb5bb5071b6b\",\n \"cumulativeGasUsed\": 23709,\n \"gasUsed\": 23709,\n \"contractAddress\": \"8e1ee0b38b719abe8fa984c986eabb5bb5071b6b\",\n \"topics\": [\n \"f0e1159fa6dc12bb31e0098b7a1270c2bd50e760522991c6f0119160028d9916\",\n \"0000000000000000000000000000000000000000000000000000000000000002\"\n ],\n \"data\": \"00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003\"\n }\n ],\n\n \"count\": 7,\n \"nextblock\": 801\n}\n" 1319 std::vector<std::vector<uint256>> hashesToBlock;
1324 auto& filterTopics = params.
topics;
1326 while (curheight == 0) {
1341 if (curheight > 0) {
1345 if (curheight == -1) {
1352 std::unique_lock<std::mutex> lock(cs_blockchange);
1353 auto blockHeight = latestblock.height;
1357 cond_blockchange.wait_for(lock, std::chrono::milliseconds(1000));
1358 if (latestblock.height > blockHeight) {
1364 LogPrintf(
"waitforlogs client disconnected\n");
1375 for (
const auto& txHashes : hashesToBlock) {
1376 for (
const auto& txHash : txHashes) {
1380 for (
const auto& receipt : receipts) {
1381 for (
const auto& log : receipt.logs) {
1383 bool includeLog =
true;
1385 if (!filterTopics.empty()) {
1386 for (
size_t i = 0; i < filterTopics.size(); i++) {
1387 auto filterTopic = filterTopics[i];
1393 auto filterTopicContent = filterTopic.get();
1394 auto topicContent = log.topics[i];
1396 if (topicContent != filterTopicContent) {
1434 std::vector<boost::optional<dev::h256>>
topics;
1437 std::unique_lock<std::mutex> lock(cs_blockchange);
1439 setFromBlock(params[0]);
1440 setToBlock(params[1]);
1442 parseParam(params[2][
"addresses"], addresses);
1453 fromBlock = latestblock.height;
1461 toBlock = latestblock.height;
1470 throw std::runtime_error(
1471 "searchlogs <fromBlock> <toBlock> (address) (topics)\n" 1472 "requires -logevents to be enabled" 1474 "1. \"fromBlock\" (numeric, required) The number of the earliest block (latest may be given to mean the most recent block).\n" 1475 "2. \"toBlock\" (string, required) The number of the latest block (-1 may be given to mean the most recent block).\n" 1476 "3. \"address\" (string, optional) An address or a list of addresses to only get logs from particular account(s).\n" 1477 "4. \"topics\" (string, optional) An array of values from which at least one must appear in the log entries. The order is important, if you want to leave topics out use null, e.g. [\"null\", \"0x00...\"]. \n" 1478 "5. \"minconf\" (uint, optional, default=0) Minimal number of confirmations before a log is returned\n" 1480 +
HelpExampleCli(
"searchlogs",
"0 100 '{\"addresses\": [\"12ae42729af478ca92c8c66773a3e32115717be4\"]}' '{\"topics\": [\"null\",\"b436c2bf863ccd7b8f63171201efd4792066b4ce8e543dde9c3e9e9ab98e216c\"]}'")
1481 +
HelpExampleRpc(
"searchlogs",
"0 100 {\"addresses\": [\"12ae42729af478ca92c8c66773a3e32115717be4\"]} {\"topics\": [\"null\",\"b436c2bf863ccd7b8f63171201efd4792066b4ce8e543dde9c3e9e9ab98e216c\"]}")
1496 std::vector<std::vector<uint256>> hashesToBlock;
1500 if (curheight == -1) {
1508 for(
const auto& hashesTx : hashesToBlock)
1510 for(
const auto&
e : hashesTx)
1514 for(
const auto& receipt : receipts) {
1515 if(receipt.logs.empty()) {
1520 for (
size_t i = 0; i <
topics.size(); i++) {
1521 const auto& tc =
topics[i];
1527 for (
const auto& log: receipt.logs) {
1528 auto filterTopicContent = tc.get();
1530 if (i >= log.topics.size()) {
1534 if (filterTopicContent == log.topics[i]) {
1559 throw std::runtime_error(
1560 "gettransactionreceipt \"hash\"\n" 1561 "requires -logevents to be enabled" 1563 "1. \"hash\" (string, required) The transaction hash\n" 1572 if(hashTemp.size() != 64){
1593 throw std::runtime_error(
1594 "listcontracts (start maxDisplay)\n" 1596 "1. start (numeric or string, optional) The starting account index, default 1\n" 1597 "2. maxDisplay (numeric or string, optional) Max accounts to list, default 20\n" 1615 if (maxDisplay <= 0)
1622 int contractsCount=(int)map.size();
1624 if (contractsCount>0 && start > contractsCount)
1627 int itStartPos=
std::min(start-1,contractsCount);
1629 for (
auto it = std::next(map.begin(),itStartPos); it!=map.end(); it++)
1633 if(i==maxDisplay)
break;
1651 CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0), nDiskSize(0), nTotalAmount(0) {}
1656 assert(!outputs.empty());
1658 ss <<
VARINT(outputs.begin()->second.nHeight * 2 + outputs.begin()->second.fCoinBase);
1660 for (
const auto output : outputs) {
1661 ss <<
VARINT(output.first + 1);
1662 ss << output.second.out.scriptPubKey;
1663 ss <<
VARINT(output.second.out.nValue);
1667 2 + output.second.out.scriptPubKey.size() ;
1675 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
1678 stats.
hashBlock = pcursor->GetBestBlock();
1685 std::map<uint32_t, Coin> outputs;
1686 while (pcursor->Valid()) {
1687 boost::this_thread::interruption_point();
1690 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
1691 if (!outputs.empty() && key.
hash != prevkey) {
1692 ApplyStats(stats, ss, prevkey, outputs);
1696 outputs[key.
n] = std::move(coin);
1698 return error(
"%s: unable to read value", __func__);
1702 if (!outputs.empty()) {
1703 ApplyStats(stats, ss, prevkey, outputs);
1713 throw std::runtime_error(
1716 "1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp\n" 1717 " to prune blocks whose block time is at least 2 hours older than the provided timestamp.\n" 1719 "n (numeric) Height of the last block pruned.\n" 1730 if (heightParam < 0)
1735 if (heightParam > 1000000000) {
1741 heightParam = pindex->
nHeight;
1744 unsigned int height = (
unsigned int) heightParam;
1746 if (chainHeight <
Params().PruneAfterHeight())
1748 else if (height > chainHeight)
1750 else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) {
1751 LogPrint(
BCLog::RPC,
"Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.");
1752 height = chainHeight - MIN_BLOCKS_TO_KEEP;
1756 return uint64_t(height);
1762 throw std::runtime_error(
1764 "\nReturns statistics about the unspent transaction output set.\n" 1765 "Note this call may take some time.\n" 1768 " \"height\":n, (numeric) The current block height (index)\n" 1769 " \"bestblock\": \"hex\", (string) the best block hash hex\n" 1770 " \"transactions\": n, (numeric) The number of transactions\n" 1771 " \"txouts\": n, (numeric) The number of output transactions\n" 1772 " \"bogosize\": n, (numeric) A meaningless metric for UTXO set size\n" 1773 " \"hash_serialized_2\": \"hash\", (string) The serialized hash\n" 1774 " \"disk_size\": n, (numeric) The estimated size of the chainstate on disk\n" 1775 " \"total_amount\": x.xxx (numeric) The total amount\n" 1805 throw std::runtime_error(
1807 "\nReturns the unspent transaction output set.\n" 1808 "Note this call may take some time.\n" 1811 " \"UTXO\": \"height, address, amount\"\n" 1826 std::map<uint32_t, Coin> outputs;
1828 while (pcursor->Valid()) {
1829 boost::this_thread::interruption_point();
1834 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
1835 if (!outputs.empty() && key.
hash != prevkey) {
1842 std::stringstream strUtxo;
1858 outputs[key.
n] = std::move(coin);
1862 ret.
push_back(
"ERROR: unable to read value");
1875 throw std::runtime_error(
1876 "gettxout \"txid\" n ( include_mempool )\n" 1877 "\nReturns details about an unspent transaction output.\n" 1879 "1. \"txid\" (string, required) The transaction id\n" 1880 "2. \"n\" (numeric, required) vout number\n" 1881 "3. \"include_mempool\" (boolean, optional) Whether to include the mempool. Default: true." 1882 " Note that an unspent output that is spent in the mempool won't appear.\n" 1885 " \"bestblock\" : \"hash\", (string) the block hash\n" 1886 " \"confirmations\" : n, (numeric) The number of confirmations\n" 1887 " \"value\" : x.xxx, (numeric) The transaction value in " +
CURRENCY_UNIT +
"\n" 1888 " \"scriptPubKey\" : { (json object)\n" 1889 " \"asm\" : \"code\", (string) \n" 1890 " \"hex\" : \"hex\", (string) \n" 1891 " \"reqSigs\" : n, (numeric) Number of required signatures\n" 1892 " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" 1893 " \"addresses\" : [ (array of string) array of fabcoin addresses\n" 1894 " \"address\" (string) fabcoin address\n" 1898 " \"coinbase\" : true|false (boolean) Coinbase or not\n" 1902 "\nGet unspent transactions\n" 1904 "\nView the details\n" 1906 "\nAs a json rpc call\n" 1918 bool fMempool =
true;
1938 if (coin.
nHeight == MEMPOOL_HEIGHT) {
1954 int nCheckLevel =
gArgs.
GetArg(
"-checklevel", DEFAULT_CHECKLEVEL);
1955 int nCheckDepth =
gArgs.
GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS);
1957 throw std::runtime_error(
1958 "verifychain ( checklevel nblocks )\n" 1959 "\nVerifies blockchain database.\n" 1961 "1. checklevel (numeric, optional, 0-4, default=" +
strprintf(
"%d", nCheckLevel) +
") How thorough the block verification is.\n" 1962 "2. nblocks (numeric, optional, default=" +
strprintf(
"%d", nCheckDepth) +
", 0=all) The number of blocks to check.\n" 1964 "true|false (boolean) Verified or not\n" 1984 bool activated =
false;
2014 switch (thresholdState) {
2048 bip9_softforks.
push_back(
Pair(name, BIP9SoftForkDesc(consensusParams,
id)));
2054 throw std::runtime_error(
2055 "getblockchaininfo\n" 2056 "Returns an object containing various state info regarding blockchain processing.\n" 2059 " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" 2060 " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" 2061 " \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n" 2062 " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" 2063 " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" 2064 " \"mediantime\": xxxxxx, (numeric) median time for the current best block\n" 2065 " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n" 2066 " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n" 2067 " \"pruned\": xx, (boolean) if the blocks are subject to pruning\n" 2068 " \"pruneheight\": xxxxxx, (numeric) lowest-height complete block stored\n" 2069 " \"softforks\": [ (array) status of softforks in progress\n" 2071 " \"id\": \"xxxx\", (string) name of softfork\n" 2072 " \"version\": xx, (numeric) block version\n" 2073 " \"reject\": { (object) progress toward rejecting pre-softfork blocks\n" 2074 " \"status\": xx, (boolean) true if threshold reached\n" 2078 " \"bip9_softforks\": { (object) status of BIP9 softforks in progress\n" 2079 " \"xxxx\" : { (string) name of the softfork\n" 2080 " \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\"\n" 2081 " \"bit\": xx, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)\n" 2082 " \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n" 2083 " \"timeout\": xx, (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n" 2084 " \"since\": xx, (numeric) height of the first block to which the status applies\n" 2085 " \"statistics\": { (object) numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)\n" 2086 " \"period\": xx, (numeric) the length in blocks of the BIP9 signalling period \n" 2087 " \"threshold\": xx, (numeric) the number of blocks with the version bit set required to activate the feature \n" 2088 " \"elapsed\": xx, (numeric) the number of blocks elapsed since the beginning of the current period \n" 2089 " \"count\": xx, (numeric) the number of blocks with the version bit set in the current period \n" 2090 " \"possible\": xx (boolean) returns false if there are not enough blocks left in this period to pass activation threshold \n" 2117 softforks.
push_back(SoftForkDesc(
"bip34", 2, tip, consensusParams));
2118 softforks.
push_back(SoftForkDesc(
"bip66", 3, tip, consensusParams));
2119 softforks.
push_back(SoftForkDesc(
"bip65", 4, tip, consensusParams));
2129 block = block->
pprev;
2154 throw std::runtime_error(
2156 "Return information about all known tips in the block tree," 2157 " including the main chain as well as orphaned branches.\n" 2161 " \"height\": xxxx, (numeric) height of the chain tip\n" 2162 " \"hash\": \"xxxx\", (string) block hash of the tip\n" 2163 " \"branchlen\": 0 (numeric) zero for main chain\n" 2164 " \"status\": \"active\" (string) \"active\" for the main chain\n" 2167 " \"height\": xxxx,\n" 2168 " \"hash\": \"xxxx\",\n" 2169 " \"branchlen\": 1 (numeric) length of branch connecting the tip to the main chain\n" 2170 " \"status\": \"xxxx\" (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)\n" 2173 "Possible values for status:\n" 2174 "1. \"invalid\" This branch contains at least one invalid block\n" 2175 "2. \"headers-only\" Not all blocks for this branch are available, but the headers are valid\n" 2176 "3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n" 2177 "4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n" 2178 "5. \"active\" This is the tip of the active main chain, which is certainly valid\n" 2193 std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
2194 std::set<const CBlockIndex*> setOrphans;
2195 std::set<const CBlockIndex*> setPrevs;
2197 for (
const std::pair<const uint256, CBlockIndex*>& item :
mapBlockIndex)
2200 setOrphans.insert(item.second);
2201 setPrevs.insert(item.second->pprev);
2205 for (std::set<const CBlockIndex*>::iterator it = setOrphans.begin(); it != setOrphans.end(); ++it)
2207 if (setPrevs.erase(*it) == 0) {
2208 setTips.insert(*it);
2233 }
else if (block->nChainTx == 0) {
2235 status =
"headers-only";
2238 status =
"valid-fork";
2241 status =
"valid-headers";
2260 size_t maxmempool =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
2270 throw std::runtime_error(
2272 "\nReturns details on the active state of the TX memory pool.\n" 2275 " \"size\": xxxxx, (numeric) Current tx count\n" 2276 " \"bytes\": xxxxx, (numeric) Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted\n" 2277 " \"usage\": xxxxx, (numeric) Total memory usage for the mempool\n" 2278 " \"maxmempool\": xxxxx, (numeric) Maximum memory usage for the mempool\n" 2279 " \"mempoolminfee\": xxxxx (numeric) Minimum feerate (" +
CURRENCY_UNIT +
" per KB) for tx to be accepted\n" 2292 throw std::runtime_error(
2293 "preciousblock \"blockhash\"\n" 2294 "\nTreats a block as if it were received before others with the same work.\n" 2295 "\nA later preciousblock call can override the effect of an earlier one.\n" 2296 "\nThe effects of preciousblock are not retained across restarts.\n" 2298 "1. \"blockhash\" (string, required) the hash of the block to mark as precious\n" 2330 throw std::runtime_error(
2331 "invalidateblock \"blockhash\"\n" 2332 "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" 2334 "1. \"blockhash\" (string, required) the hash of the block to mark as invalid\n" 2368 throw std::runtime_error(
2369 "reconsiderblock \"blockhash\"\n" 2370 "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n" 2371 "This can be used to undo the effects of invalidateblock.\n" 2373 "1. \"blockhash\" (string, required) the hash of the block to reconsider\n" 2405 throw std::runtime_error(
2406 "getchaintxstats ( nblocks blockhash )\n" 2407 "\nCompute statistics about the total number and rate of transactions in the chain.\n" 2409 "1. nblocks (numeric, optional) Size of the window in number of blocks (default: one month).\n" 2410 "2. \"blockhash\" (string, optional) The hash of the block that ends the window.\n" 2413 " \"time\": xxxxx, (numeric) The timestamp for the statistics in UNIX format.\n" 2414 " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" 2415 " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window.\n" 2442 pindex = it->second;
2451 if (blockcount < 1 || blockcount >= pindex->
nHeight) {
2462 ret.
push_back(
Pair(
"txrate", ((
double)nTxDiff) / nTimeDiff));
2471 {
"blockchain",
"getchaintxstats", &
getchaintxstats,
true, {
"nblocks",
"blockhash"} },
2473 {
"blockchain",
"getblockcount", &
getblockcount,
true, {} },
2474 {
"blockchain",
"getblock", &
getblock,
true, {
"blockhash",
"verbosity|verbose",
"legacy"} },
2475 {
"blockchain",
"getblockhash", &
getblockhash,
true, {
"height"} },
2476 {
"blockchain",
"getblockheader", &
getblockheader,
true, {
"blockhash",
"verbose",
"legacy"} },
2477 {
"blockchain",
"getchaintips", &
getchaintips,
true, {} },
2478 {
"blockchain",
"getdifficulty", &
getdifficulty,
true, {} },
2481 {
"blockchain",
"getmempoolentry", &
getmempoolentry,
true, {
"txid"} },
2483 {
"blockchain",
"getrawmempool", &
getrawmempool,
true, {
"verbose"} },
2484 {
"blockchain",
"gettxout", &
gettxout,
true, {
"txid",
"n",
"include_mempool"} },
2486 {
"blockchain",
"gettxoutset", &
gettxoutset,
true, {} },
2487 {
"blockchain",
"pruneblockchain", &
pruneblockchain,
true, {
"height"} },
2488 {
"blockchain",
"verifychain", &
verifychain,
true, {
"checklevel",
"nblocks"} },
2489 {
"blockchain",
"getaccountinfo", &
getaccountinfo,
true, {
"contract_address"} },
2490 {
"blockchain",
"getstorage", &
getstorage,
true, {
"address, index, blockNum"} },
2492 {
"blockchain",
"preciousblock", &
preciousblock,
true, {
"blockhash"} },
2494 {
"blockchain",
"callcontract", &
callcontract,
true, {
"address",
"data"} },
2496 {
"hidden",
"invalidateblock", &
invalidateblock,
true, {
"blockhash"} },
2497 {
"hidden",
"reconsiderblock", &
reconsiderblock,
true, {
"blockhash"} },
2499 {
"hidden",
"waitforblock", &
waitforblock,
true, {
"blockhash",
"timeout"} },
2501 {
"blockchain",
"listcontracts", &
listcontracts,
true, {
"start",
"maxDisplay"} },
2503 {
"blockchain",
"searchlogs", &
searchlogs,
true, {
"fromBlock",
"toBlock",
"address",
"topics"} },
2504 {
"blockchain",
"waitforlogs", &
waitforlogs,
true, {
"fromBlock",
"nblocks",
"address",
"topics"} },
2509 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
const std::string CURRENCY_UNIT
CAmount GetFeePerK() const
Return the fee in liu for a size of 1000 bytes.
CodeDeposit codeDeposit
Failed if an attempted deposit failed due to lack of gas.
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
CAmount GetModFeesWithAncestors() const
bool error(const char *fmt, const Args &...args)
const std::string & get_str() const
uint64_t nTransactionOutputs
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool fPruneMode
True if we're running in -prune mode.
unsigned int GetHeight() const
bool operator()(const CBlockIndex *a, const CBlockIndex *b) const
std::vector< TransactionReceiptInfo > getResult(dev::h256 const &hashTx)
UniValue getmempoolancestors(const JSONRPCRequest &request)
Fabcoin RPC command dispatcher.
UniValue getblock(const JSONRPCRequest &request)
const_iterator begin() const
CBlockIndex * pprev
pointer to the index of the predecessor of this block
bool IsRPCRunning()
Query whether RPC is running.
uint64_t GetCountWithAncestors() const
uint64_t GetCountWithDescendants() const
UniValue getbestblockhash(const JSONRPCRequest &request)
UniValue reconsiderblock(const JSONRPCRequest &request)
bool VerifyDB(const CChainParams &chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
bool InvalidateBlock(CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex)
Mark a block as invalid.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool fHavePruned
Pruning-related variables and constants.
bool isSpent(const COutPoint &outpoint)
LogBloom const & bloom() const
void assignJSON(UniValue &entry, const TransactionReceiptInfo &resExec)
UniValue preciousblock(const JSONRPCRequest &request)
UniValue transactionReceiptToJSON(const dev::eth::TransactionReceipt &txRec)
size_t GetSerializeSize(const T &t, int nType, int nVersion=0)
UniValue mempoolInfoToJSON()
Mempool information to JSON.
Comparison function for sorting the getchaintips heads.
const std::vector< UniValue > & getValues() const
std::string GetHex() const
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
bool FlushStateToDisk()
Flush all state, indexes and buffers to disk.
const Consensus::Params & GetConsensus() const
base58-encoded Fabcoin addresses.
void setToBlock(const UniValue &val)
CTxOut out
unspent transaction output
h160 Address
An Ethereum address: 20 bytes.
UniValue ValueFromAmount(const CAmount &amount)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
unsigned int fCoinBase
whether containing transaction was a coinbase
UniValue blockheaderToJSON(const CBlockIndex *blockindex)
Block header to JSON.
int BIP66Height
Block height at which BIP66 becomes active.
BIP9Stats VersionBitsTipStatistics(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the numerical statistics for the BIP9 state for a given deployment at the current tip...
h256 const & stateRoot() const
uint64_t GetTotalTxSize()
std::set< txiter, CompareIteratorByHash > setEntries
void queryHashes(std::vector< uint256 > &vtxid)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
assert(len-trim+(2 *lenIndices)<=WIDTH)
UniValue listcontracts(const JSONRPCRequest &request)
size_t DynamicMemoryUsage() const
Double ended buffer combining vector and stream-like interfaces.
size_t parseUInt(const UniValue &val, size_t defaultVal)
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index, or the chain tip if not provided...
SearchLogsParams(const UniValue ¶ms)
bool IsSupportContract() const
UniValue verifychain(const JSONRPCRequest &request)
uint64_t GetUint64(int pos) const
std::vector< boost::optional< dev::h256 > > topics
Description of the result of executing a transaction.
UniValue getblockcount(const JSONRPCRequest &request)
UniValue executionResultToJSON(const dev::eth::ExecutionResult &exRes)
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
UniValue waitfornewblock(const JSONRPCRequest &request)
double GuessVerificationProgress(const ChainTxData &data, CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index.
virtual CCoinsViewCursor * Cursor() const
Get a cursor to iterate over the whole state.
unsigned int nChainTx
(memory only) Number of transactions in the chain up to and including this block. ...
UniValue getchaintips(const JSONRPCRequest &request)
bool ActivateBestChain(CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
Make the best chain active, in multiple steps.
UniValue getmempooldescendants(const JSONRPCRequest &request)
const std::vector< CTxIn > vin
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
ThresholdState VersionBitsTipState(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment at the current tip.
u256 const & gasUsed() const
arith_uint256 UintToArith256(const uint256 &a)
UniValue gettxoutset(const JSONRPCRequest &request)
UniValue waitforblock(const JSONRPCRequest &request)
std::string ToString() const
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
indexed_transaction_set mapTx
int64_t CAmount
Amount in lius (Can be negative)
int64_t GetnPowTargetSpacing(uint32_t nHeight=0) const
UniValue gettransactionreceipt(const JSONRPCRequest &request)
uint64_t GetSizeWithDescendants() const
UniValue searchlogs(const JSONRPCRequest &request)
bool ReadBlockFromDisk(Block &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
#define AssertLockHeld(cs)
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
const CAmount & GetFee() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
void setFromBlock(const UniValue &val)
UniValue getaccountinfo(const JSONRPCRequest &request)
int Height() const
Return the maximal height in the chain.
uint32_t GetCompact(bool fNegative=false) const
int64_t get_int64() const
bool push_back(const UniValue &val)
dev::h256 uintToh256(const uint256 &in)
dev::eth::LogEntries logs
UniValue pruneblockchain(const JSONRPCRequest &request)
unsigned int nStatus
Verification status of this block. See enum BlockStatus.
UniValue waitforblockheight(const JSONRPCRequest &request)
CBlockIndex * Next(const CBlockIndex *pindex) const
Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip...
void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry)
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
CBlockHeader GetBlockHeader() const
std::set< dev::h160 > addresses
void RegisterBlockchainRPCCommands(CRPCTable &t)
Register block chain RPC commands.
Abstract view on the open txout dataset.
void parseParam(const UniValue &val, std::vector< dev::h160 > &h160s)
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
An input of a transaction.
UniValue getmempoolinfo(const JSONRPCRequest &request)
int BIP34Height
Block height and hash at which BIP34 becomes active.
CAmount GetModFeesWithDescendants() const
uint256 uint256S(const char *str)
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
dev::Address contractAddress
void CalculateDescendants(txiter it, setEntries &setDescendants)
Populate setDescendants with all in-mempool descendants of hash.
uint32_t ContractHeight
Block height at which Fabcoin Smart Contract hard fork becomes active.
UniValue getdifficulty(const JSONRPCRequest &request)
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
double GetDifficultyINTERNAL(const CBlockIndex *blockindex)
Unexpected type was passed as parameter.
UniValue getchaintxstats(const JSONRPCRequest &request)
UniValue callcontract(const JSONRPCRequest &request)
UniValue gettxoutsetinfo(const JSONRPCRequest &request)
UniValue getblockhash(const JSONRPCRequest &request)
std::string ToString() const
General application defined errors.
int VersionBitsTipStateSinceHeight(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the block height at which the BIP9 deployment switched into the state for the block building on t...
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
std::set< dev::h160 > addresses
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue getmempoolentry(const JSONRPCRequest &request)
Parameters that influence chain consensus.
UniValue waitforlogs(const JSONRPCRequest &request_)
An outpoint - a combination of a transaction hash and an index n into its vout.
int parseBlockHeight(const UniValue &val)
std::string GetHex() const
uint64_t GetSizeWithAncestors() const
UniValue gettxout(const JSONRPCRequest &request)
void BIP9SoftForkDescPushBack(UniValue &bip9_softforks, const std::string &name, const Consensus::Params &consensusParams, Consensus::DeploymentPos id)
void PollStart()
Start long-polling.
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
TransactionException excepted
UniValue mempoolToJSON(bool fVerbose)
Mempool to JSON.
bool PollAlive()
Returns whether the underlying long-poll connection is still alive.
int BIP65Height
Block height at which BIP65 becomes active.
dev::h160 parseParamH160(const UniValue &val)
bool exists(uint256 hash) const
bool CheckHex(const std::string &str)
CBlockIndex * FindEarliestAtLeast(int64_t nTime) const
Find the earliest block with timestamp equal or greater than the given.
WaitForLogsParams(const UniValue ¶ms)
std::string GetRejectReason() const
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
#define LogPrint(category,...)
std::string ToString() const
UniValue getstorage(const JSONRPCRequest &request)
void SetRoot(dev::h256 newHashStateRoot, dev::h256 newHashUTXORoot)
std::vector< ResultExecute > CallContract(const dev::Address &addrContract, std::vector< unsigned char > opcode, const dev::Address &sender, uint64_t gasLimit)
void PollPing()
Ping long-poll connection with an empty character to make sure it's still alive.
Capture information about block/transaction validation.
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
bool IsLegacyFormat() const
u256 gasForDeposit
Amount of gas remaining for the code deposit phase.
const CTransaction & GetTx() const
std::vector< CTransactionRef > vtx
std::vector< h160 > h160s
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
UniValue invalidateblock(const JSONRPCRequest &request)
int64_t GetModifiedFee() const
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
dev::eth::TransactionException excepted
double GetDifficultyBitcoin(const CBlockIndex *blockindex)
PlatformStyle::TableColorType type
void transactionReceiptInfoToJSON(const TransactionReceiptInfo &resExec, UniValue &entry)
bool ResetBlockFailureFlags(CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
UniValue getrawmempool(const JSONRPCRequest &request)
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
UniValue getblockchaininfo(const JSONRPCRequest &request)
void PruneBlockFilesManual(int nManualPruneHeight)
Prune block files up to a given height.
UniValue getblockheader(const JSONRPCRequest &request)
bool PreciousBlock(CValidationState &state, const CChainParams ¶ms, CBlockIndex *pindex)
Mark a block as precious and reorganize.
A reference to a CKey: the Hash160 of its serialized public key.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
unsigned depositSize
Amount of code of the creation's attempted deposit.
const UniValue NullUniValue
void writeVMlog(const std::vector< ResultExecute > &res, const CTransaction &tx, const CBlock &block)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
A writer stream (for serialization) that computes a 256-bit hash.
void parseFilter(const UniValue &val)
const uint256 & GetHash() const
std::vector< unsigned char > valtype
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex)
Callback for when block tip changed.
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
CCoinsViewCursor * Cursor() const override
Get a cursor to iterate over the whole state.
UniValue JSONRPCError(int code, const std::string &message)
uint32_t transactionIndex
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
std::string EntryDescriptionString()
int bit
Bit position to select the particular bit in nVersion.
CCoinsViewDB * pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
full block available in blk*.dat
std::vector< h256 > h256s
UniValue blockToJSON(const CBlock &block, const CBlockIndex *blockindex, bool txDetails)
Block description to JSON.
std::vector< boost::optional< dev::h256 > > topics
uint64_t cumulativeGasUsed
void ScriptPubKeyToJSON(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
int64_t GetMedianTimePast() const
CCoinsView that brings transactions from a memorypool into view.
int ReadHeightIndex(int low, int high, int minconf, std::vector< std::vector< uint256 >> &blocksOfHashes, std::set< dev::h160 > const &addresses)
Iterates through blocks by height, starting from low.
unsigned int nTx
Number of transactions in this block.
std::unique_ptr< FascState > globalState
Global state.
StorageResults * pstorageresult
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const
Try to calculate all in-mempool ancestors of entry.
std::vector< unsigned char > nSolution
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
std::string itostr(int n)
uint256 GetBlockHash() const
std::vector< LogEntry > LogEntries
const_iterator end() const
std::vector< unsigned char > ParseHex(const char *psz)
LogEntries const & log() const