Master Core  v0.0.9 - 49a5c0d97abf09ef2911ddfe8d9551df59f9efd3-dirty
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rpcblockchain.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2013 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "rpcserver.h"
7 #include "main.h"
8 #include "sync.h"
9 #include "checkpoints.h"
10 
11 #include <stdint.h>
12 
13 #include "json/json_spirit_value.h"
14 
15 using namespace json_spirit;
16 using namespace std;
17 
18 void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
19 
20 double GetDifficulty(const CBlockIndex* blockindex)
21 {
22  // Floating point number that is a multiple of the minimum difficulty,
23  // minimum difficulty = 1.0.
24  if (blockindex == NULL)
25  {
26  if (chainActive.Tip() == NULL)
27  return 1.0;
28  else
29  blockindex = chainActive.Tip();
30  }
31 
32  int nShift = (blockindex->nBits >> 24) & 0xff;
33 
34  double dDiff =
35  (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
36 
37  while (nShift < 29)
38  {
39  dDiff *= 256.0;
40  nShift++;
41  }
42  while (nShift > 29)
43  {
44  dDiff /= 256.0;
45  nShift--;
46  }
47 
48  return dDiff;
49 }
50 
51 
52 Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
53 {
54  Object result;
55  result.push_back(Pair("hash", block.GetHash().GetHex()));
56  CMerkleTx txGen(block.vtx[0]);
57  txGen.SetMerkleBranch(&block);
58  result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
59  result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
60  result.push_back(Pair("height", blockindex->nHeight));
61  result.push_back(Pair("version", block.nVersion));
62  result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
63  Array txs;
64  BOOST_FOREACH(const CTransaction&tx, block.vtx)
65  txs.push_back(tx.GetHash().GetHex());
66  result.push_back(Pair("tx", txs));
67  result.push_back(Pair("time", block.GetBlockTime()));
68  result.push_back(Pair("nonce", (uint64_t)block.nNonce));
69  result.push_back(Pair("bits", HexBits(block.nBits)));
70  result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
71  result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
72 
73  if (blockindex->pprev)
74  result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
75  CBlockIndex *pnext = chainActive.Next(blockindex);
76  if (pnext)
77  result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));
78  return result;
79 }
80 
81 
82 Value getblockcount(const Array& params, bool fHelp)
83 {
84  if (fHelp || params.size() != 0)
85  throw runtime_error(
86  "getblockcount\n"
87  "\nReturns the number of blocks in the longest block chain.\n"
88  "\nResult:\n"
89  "n (numeric) The current block count\n"
90  "\nExamples:\n"
91  + HelpExampleCli("getblockcount", "")
92  + HelpExampleRpc("getblockcount", "")
93  );
94 
95  return chainActive.Height();
96 }
97 
98 Value getbestblockhash(const Array& params, bool fHelp)
99 {
100  if (fHelp || params.size() != 0)
101  throw runtime_error(
102  "getbestblockhash\n"
103  "\nReturns the hash of the best (tip) block in the longest block chain.\n"
104  "\nResult\n"
105  "\"hex\" (string) the block hash hex encoded\n"
106  "\nExamples\n"
107  + HelpExampleCli("getbestblockhash", "")
108  + HelpExampleRpc("getbestblockhash", "")
109  );
110 
111  return chainActive.Tip()->GetBlockHash().GetHex();
112 }
113 
114 Value getdifficulty(const Array& params, bool fHelp)
115 {
116  if (fHelp || params.size() != 0)
117  throw runtime_error(
118  "getdifficulty\n"
119  "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
120  "\nResult:\n"
121  "n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
122  "\nExamples:\n"
123  + HelpExampleCli("getdifficulty", "")
124  + HelpExampleRpc("getdifficulty", "")
125  );
126 
127  return GetDifficulty();
128 }
129 
130 
131 Value getrawmempool(const Array& params, bool fHelp)
132 {
133  if (fHelp || params.size() > 1)
134  throw runtime_error(
135  "getrawmempool ( verbose )\n"
136  "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
137  "\nArguments:\n"
138  "1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
139  "\nResult: (for verbose = false):\n"
140  "[ (json array of string)\n"
141  " \"transactionid\" (string) The transaction id\n"
142  " ,...\n"
143  "]\n"
144  "\nResult: (for verbose = true):\n"
145  "{ (json object)\n"
146  " \"transactionid\" : { (json object)\n"
147  " \"size\" : n, (numeric) transaction size in bytes\n"
148  " \"fee\" : n, (numeric) transaction fee in bitcoins\n"
149  " \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
150  " \"height\" : n, (numeric) block height when transaction entered pool\n"
151  " \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
152  " \"currentpriority\" : n, (numeric) transaction priority now\n"
153  " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
154  " \"transactionid\", (string) parent transaction id\n"
155  " ... ]\n"
156  " }, ...\n"
157  "]\n"
158  "\nExamples\n"
159  + HelpExampleCli("getrawmempool", "true")
160  + HelpExampleRpc("getrawmempool", "true")
161  );
162 
163  bool fVerbose = false;
164  if (params.size() > 0)
165  fVerbose = params[0].get_bool();
166 
167  if (fVerbose)
168  {
169  LOCK(mempool.cs);
170  Object o;
171  BOOST_FOREACH(const PAIRTYPE(uint256, CTxMemPoolEntry)& entry, mempool.mapTx)
172  {
173  const uint256& hash = entry.first;
174  const CTxMemPoolEntry& e = entry.second;
175  Object info;
176  info.push_back(Pair("size", (int)e.GetTxSize()));
177  info.push_back(Pair("fee", ValueFromAmount(e.GetFee())));
178  info.push_back(Pair("time", e.GetTime()));
179  info.push_back(Pair("height", (int)e.GetHeight()));
180  info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight())));
181  info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height())));
182  const CTransaction& tx = e.GetTx();
183  set<string> setDepends;
184  BOOST_FOREACH(const CTxIn& txin, tx.vin)
185  {
186  if (mempool.exists(txin.prevout.hash))
187  setDepends.insert(txin.prevout.hash.ToString());
188  }
189  Array depends(setDepends.begin(), setDepends.end());
190  info.push_back(Pair("depends", depends));
191  o.push_back(Pair(hash.ToString(), info));
192  }
193  return o;
194  }
195  else
196  {
197  vector<uint256> vtxid;
198  mempool.queryHashes(vtxid);
199 
200  Array a;
201  BOOST_FOREACH(const uint256& hash, vtxid)
202  a.push_back(hash.ToString());
203 
204  return a;
205  }
206 }
207 
208 Value getblockhash(const Array& params, bool fHelp)
209 {
210  if (fHelp || params.size() != 1)
211  throw runtime_error(
212  "getblockhash index\n"
213  "\nReturns hash of block in best-block-chain at index provided.\n"
214  "\nArguments:\n"
215  "1. index (numeric, required) The block index\n"
216  "\nResult:\n"
217  "\"hash\" (string) The block hash\n"
218  "\nExamples:\n"
219  + HelpExampleCli("getblockhash", "1000")
220  + HelpExampleRpc("getblockhash", "1000")
221  );
222 
223  int nHeight = params[0].get_int();
224  if (nHeight < 0 || nHeight > chainActive.Height())
225  throw runtime_error("Block number out of range.");
226 
227  CBlockIndex* pblockindex = chainActive[nHeight];
228  return pblockindex->GetBlockHash().GetHex();
229 }
230 
231 Value getblock(const Array& params, bool fHelp)
232 {
233  if (fHelp || params.size() < 1 || params.size() > 2)
234  throw runtime_error(
235  "getblock \"hash\" ( verbose )\n"
236  "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
237  "If verbose is true, returns an Object with information about block <hash>.\n"
238  "\nArguments:\n"
239  "1. \"hash\" (string, required) The block hash\n"
240  "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
241  "\nResult (for verbose = true):\n"
242  "{\n"
243  " \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
244  " \"confirmations\" : n, (numeric) The number of confirmations\n"
245  " \"size\" : n, (numeric) The block size\n"
246  " \"height\" : n, (numeric) The block height or index\n"
247  " \"version\" : n, (numeric) The block version\n"
248  " \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
249  " \"tx\" : [ (array of string) The transaction ids\n"
250  " \"transactionid\" (string) The transaction id\n"
251  " ,...\n"
252  " ],\n"
253  " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
254  " \"nonce\" : n, (numeric) The nonce\n"
255  " \"bits\" : \"1d00ffff\", (string) The bits\n"
256  " \"difficulty\" : x.xxx, (numeric) The difficulty\n"
257  " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
258  " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
259  "}\n"
260  "\nResult (for verbose=false):\n"
261  "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
262  "\nExamples:\n"
263  + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
264  + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
265  );
266 
267  std::string strHash = params[0].get_str();
268  uint256 hash(strHash);
269 
270  bool fVerbose = true;
271  if (params.size() > 1)
272  fVerbose = params[1].get_bool();
273 
274  if (mapBlockIndex.count(hash) == 0)
275  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
276 
277  CBlock block;
278  CBlockIndex* pblockindex = mapBlockIndex[hash];
279 
280  if(!ReadBlockFromDisk(block, pblockindex))
281  throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
282 
283  if (!fVerbose)
284  {
286  ssBlock << block;
287  std::string strHex = HexStr(ssBlock.begin(), ssBlock.end());
288  return strHex;
289  }
290 
291  return blockToJSON(block, pblockindex);
292 }
293 
294 Value gettxoutsetinfo(const Array& params, bool fHelp)
295 {
296  if (fHelp || params.size() != 0)
297  throw runtime_error(
298  "gettxoutsetinfo\n"
299  "\nReturns statistics about the unspent transaction output set.\n"
300  "Note this call may take some time.\n"
301  "\nResult:\n"
302  "{\n"
303  " \"height\":n, (numeric) The current block height (index)\n"
304  " \"bestblock\": \"hex\", (string) the best block hash hex\n"
305  " \"transactions\": n, (numeric) The number of transactions\n"
306  " \"txouts\": n, (numeric) The number of output transactions\n"
307  " \"bytes_serialized\": n, (numeric) The serialized size\n"
308  " \"hash_serialized\": \"hash\", (string) The serialized hash\n"
309  " \"total_amount\": x.xxx (numeric) The total amount\n"
310  "}\n"
311  "\nExamples:\n"
312  + HelpExampleCli("gettxoutsetinfo", "")
313  + HelpExampleRpc("gettxoutsetinfo", "")
314  );
315 
316  Object ret;
317 
318  CCoinsStats stats;
319  if (pcoinsTip->GetStats(stats)) {
320  ret.push_back(Pair("height", (int64_t)stats.nHeight));
321  ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
322  ret.push_back(Pair("transactions", (int64_t)stats.nTransactions));
323  ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs));
324  ret.push_back(Pair("bytes_serialized", (int64_t)stats.nSerializedSize));
325  ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex()));
326  ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount)));
327  }
328  return ret;
329 }
330 
331 Value gettxout(const Array& params, bool fHelp)
332 {
333  if (fHelp || params.size() < 2 || params.size() > 3)
334  throw runtime_error(
335  "gettxout \"txid\" n ( includemempool )\n"
336  "\nReturns details about an unspent transaction output.\n"
337  "\nArguments:\n"
338  "1. \"txid\" (string, required) The transaction id\n"
339  "2. n (numeric, required) vout value\n"
340  "3. includemempool (boolean, optional) Whether to included the mem pool\n"
341  "\nResult:\n"
342  "{\n"
343  " \"bestblock\" : \"hash\", (string) the block hash\n"
344  " \"confirmations\" : n, (numeric) The number of confirmations\n"
345  " \"value\" : x.xxx, (numeric) The transaction value in btc\n"
346  " \"scriptPubKey\" : { (json object)\n"
347  " \"asm\" : \"code\", (string) \n"
348  " \"hex\" : \"hex\", (string) \n"
349  " \"reqSigs\" : n, (numeric) Number of required signatures\n"
350  " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n"
351  " \"addresses\" : [ (array of string) array of bitcoin addresses\n"
352  " \"bitcoinaddress\" (string) bitcoin address\n"
353  " ,...\n"
354  " ]\n"
355  " },\n"
356  " \"version\" : n, (numeric) The version\n"
357  " \"coinbase\" : true|false (boolean) Coinbase or not\n"
358  "}\n"
359 
360  "\nExamples:\n"
361  "\nGet unspent transactions\n"
362  + HelpExampleCli("listunspent", "") +
363  "\nView the details\n"
364  + HelpExampleCli("gettxout", "\"txid\" 1") +
365  "\nAs a json rpc call\n"
366  + HelpExampleRpc("gettxout", "\"txid\", 1")
367  );
368 
369  Object ret;
370 
371  std::string strHash = params[0].get_str();
372  uint256 hash(strHash);
373  int n = params[1].get_int();
374  bool fMempool = true;
375  if (params.size() > 2)
376  fMempool = params[2].get_bool();
377 
378  CCoins coins;
379  if (fMempool) {
380  LOCK(mempool.cs);
382  if (!view.GetCoins(hash, coins))
383  return Value::null;
384  mempool.pruneSpent(hash, coins); // TODO: this should be done by the CCoinsViewMemPool
385  } else {
386  if (!pcoinsTip->GetCoins(hash, coins))
387  return Value::null;
388  }
389  if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull())
390  return Value::null;
391 
392  std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
393  CBlockIndex *pindex = it->second;
394  ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex()));
395  if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)
396  ret.push_back(Pair("confirmations", 0));
397  else
398  ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
399  ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
400  Object o;
401  ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
402  ret.push_back(Pair("scriptPubKey", o));
403  ret.push_back(Pair("version", coins.nVersion));
404  ret.push_back(Pair("coinbase", coins.fCoinBase));
405 
406  return ret;
407 }
408 
409 Value verifychain(const Array& params, bool fHelp)
410 {
411  if (fHelp || params.size() > 2)
412  throw runtime_error(
413  "verifychain ( checklevel numblocks )\n"
414  "\nVerifies blockchain database.\n"
415  "\nArguments:\n"
416  "1. checklevel (numeric, optional, 0-4, default=3) How thorough the block verification is.\n"
417  "2. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
418  "\nResult:\n"
419  "true|false (boolean) Verified or not\n"
420  "\nExamples:\n"
421  + HelpExampleCli("verifychain", "")
422  + HelpExampleRpc("verifychain", "")
423  );
424 
425  int nCheckLevel = GetArg("-checklevel", 3);
426  int nCheckDepth = GetArg("-checkblocks", 288);
427  if (params.size() > 0)
428  nCheckLevel = params[0].get_int();
429  if (params.size() > 1)
430  nCheckDepth = params[1].get_int();
431 
432  return VerifyDB(nCheckLevel, nCheckDepth);
433 }
434 
435 Value getblockchaininfo(const Array& params, bool fHelp)
436 {
437  if (fHelp || params.size() != 0)
438  throw runtime_error(
439  "getblockchaininfo\n"
440  "Returns an object containing various state info regarding block chain processing.\n"
441  "\nResult:\n"
442  "{\n"
443  " \"chain\": \"xxxx\", (string) current chain (main, testnet3, regtest)\n"
444  " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
445  " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
446  " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
447  " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
448  " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
449  "}\n"
450  "\nExamples:\n"
451  + HelpExampleCli("getblockchaininfo", "")
452  + HelpExampleRpc("getblockchaininfo", "")
453  );
454 
455  proxyType proxy;
456  GetProxy(NET_IPV4, proxy);
457 
458  Object obj;
459  std::string chain = Params().DataDir();
460  if(chain.empty())
461  chain = "main";
462  obj.push_back(Pair("chain", chain));
463  obj.push_back(Pair("blocks", (int)chainActive.Height()));
464  obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
465  obj.push_back(Pair("difficulty", (double)GetDifficulty()));
466  obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip())));
467  obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
468  return obj;
469 }
const string & DataDir() const
Definition: chainparams.h:63
uint64_t nTransactionOutputs
Definition: coins.h:248
unsigned int GetHeight() const
Definition: txmempool.h:41
int nVersion
Definition: core.h:349
int64_t nTotalAmount
Definition: coins.h:251
uint256 hashBlock
Definition: coins.h:246
const_iterator begin() const
Definition: serialize.h:924
CBlockIndex * pprev
Definition: main.h:695
std::vector< CTxOut > vout
Definition: coins.h:75
void ScriptPubKeyToJSON(const CScript &scriptPubKey, Object &out, bool fIncludeHex)
int nHeight
Definition: coins.h:245
Definition: core.h:396
#define PAIRTYPE(t1, t2)
Definition: util.h:48
Value getblockcount(const Array &params, bool fHelp)
std::string HelpExampleRpc(string methodname, string args)
Definition: rpcserver.cpp:923
int nHeight
Definition: coins.h:78
bool VerifyDB(int nCheckLevel, int nCheckDepth)
Verify consistency of the block and coin databases.
Definition: main.cpp:2923
uint256 GetHash() const
Definition: core.cpp:75
uint64_t nTransactions
Definition: coins.h:247
uint256 GetBestBlock()
Definition: coins.cpp:113
void queryHashes(std::vector< uint256 > &vtxid)
Definition: txmempool.cpp:179
Value gettxoutsetinfo(const Array &params, bool fHelp)
STL namespace.
Object blockToJSON(const CBlock &block, const CBlockIndex *blockindex)
Double ended buffer combining vector and stream-like interfaces.
Definition: serialize.h:839
Object JSONRPCError(int code, const string &message)
Value getblockchaininfo(const Array &params, bool fHelp)
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
Definition: coins.h:68
Value getblock(const Array &params, bool fHelp)
uint256 nChainWork
Definition: main.h:710
bool GetStats(CCoinsStats &stats)
Definition: coins.cpp:70
Value getdifficulty(const Array &params, bool fHelp)
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:48
bool GetCoins(const uint256 &txid, CCoins &coins)
Definition: coins.cpp:74
Definition: txmempool.h:20
uint256 hashSerialized
Definition: coins.h:250
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or NULL if none.
Definition: main.h:1012
int Height() const
Return the maximal height in the chain.
Definition: main.h:1043
std::string HexBits(unsigned int nBits)
Definition: rpcserver.cpp:99
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...
Definition: main.h:1035
Value ValueFromAmount(int64_t amount)
Definition: rpcserver.cpp:94
int nVersion
Definition: coins.h:82
uint256 hashMerkleRoot
Definition: core.h:351
unsigned int GetSerializeSize(char a, int, int=0)
Definition: serialize.h:105
int64_t GetBlockTime() const
Definition: core.h:389
An input of a transaction.
Definition: core.h:70
#define LOCK(cs)
Definition: sync.h:156
uint64_t nSerializedSize
Definition: coins.h:249
bool GetCoins(const uint256 &txid, CCoins &coins)
Definition: txmempool.cpp:200
std::vector< CTxIn > vin
Definition: core.h:190
unsigned int nBits
Definition: main.h:726
double GetPriority(unsigned int currentHeight) const
Definition: txmempool.cpp:30
int64_t GetTime() const
Definition: txmempool.h:40
std::map< uint256, CTxMemPoolEntry > mapTx
Definition: txmempool.h:62
unsigned int nNonce
Definition: core.h:354
Value getrawmempool(const Array &params, bool fHelp)
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
Definition: main.cpp:413
std::string GetHex() const
Definition: uint256.h:297
double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks)
CCriticalSection cs
Definition: txmempool.h:61
CTxMemPool mempool
Definition: main.cpp:45
bool fCoinBase
Definition: coins.h:72
256-bit unsigned integer
Definition: uint256.h:531
void pruneSpent(const uint256 &hash, CCoins &coins)
Definition: txmempool.cpp:46
const CTransaction & GetTx() const
Definition: txmempool.h:36
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
Definition: main.cpp:1145
uint256 GetHash() const
Definition: core.cpp:215
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: main.h:688
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:401
std::string ToString() const
Definition: uint256.h:340
static const int PROTOCOL_VERSION
Definition: version.h:29
double GetDifficulty(const CBlockIndex *blockindex)
bool exists(uint256 hash)
Definition: txmempool.h:91
int GetDepthInMainChain(CBlockIndex *&pindexRet) const
Definition: main.cpp:1023
std::pair< CService, int > proxyType
Definition: netbase.h:136
Value getbestblockhash(const Array &params, bool fHelp)
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
Definition: netbase.cpp:430
std::string HelpExampleCli(string methodname, string args)
Definition: rpcserver.cpp:919
std::vector< CTransaction > vtx
Definition: core.h:400
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Definition: util.cpp:505
Value getblockhash(const Array &params, bool fHelp)
static const unsigned int MEMPOOL_HEIGHT
Fake height value used in CCoins to signify they are only in the memory pool (since 0...
Definition: txmempool.h:15
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: core.h:183
Value gettxout(const Array &params, bool fHelp)
int nHeight
Definition: main.h:698
int64_t GetFee() const
Definition: txmempool.h:38
unsigned int nBits
Definition: core.h:353
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Definition: util.h:263
COutPoint prevout
Definition: core.h:73
Value verifychain(const Array &params, bool fHelp)
CCoinsView that brings transactions from a memorypool into view.
Definition: txmempool.h:102
map< uint256, CBlockIndex * > mapBlockIndex
Definition: main.cpp:47
size_t GetTxSize() const
Definition: txmempool.h:39
uint256 GetBlockHash() const
Definition: main.h:805
A transaction with a merkle branch linking it to the block chain.
Definition: main.h:426
const_iterator end() const
Definition: serialize.h:926
uint256 hash
Definition: core.h:25