18 if (blockindex == NULL)
26 int nShift = (blockindex->
nBits >> 24) & 0xff;
29 (double)0x0000ffff / (
double)(blockindex->
nBits & 0x00ffffff);
51 txGen.SetMerkleBranch(&block);
54 result.push_back(
Pair(
"height", blockindex->
nHeight));
60 result.push_back(
Pair(
"tx", txs));
66 if (blockindex->
pprev)
68 if (blockindex->
pnext)
76 if (fHelp || params.size() != 0)
79 "Returns the number of blocks in the longest block chain.");
86 if (fHelp || params.size() != 0)
89 "Returns the hash of the best (tip) block in the longest block chain.");
96 if (fHelp || params.size() != 0)
99 "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
107 if (fHelp || params.size() < 1 || params.size() > 1)
109 "settxfee <amount>\n"
110 "<amount> is a real and is rounded to the nearest 0.00000001");
114 if (params[0].get_real() != 0.0)
123 if (fHelp || params.size() != 0)
126 "Returns all transaction ids in memory pool.");
128 vector<uint256> vtxid;
140 if (fHelp || params.size() != 1)
142 "getblockhash <index>\n"
143 "Returns hash of block in best-block-chain at <index>.");
145 int nHeight = params[0].
get_int();
147 throw runtime_error(
"Block number out of range.");
155 if (fHelp || params.size() < 1 || params.size() > 2)
157 "getblock <hash> [verbose=true]\n"
158 "If verbose is false, returns a string that is serialized, hex-encoded data for block <hash>.\n"
159 "If verbose is true, returns an Object with information about block <hash>."
162 std::string strHash = params[0].
get_str();
165 bool fVerbose =
true;
166 if (params.size() > 1)
167 fVerbose = params[1].get_bool();
189 if (fHelp || params.size() != 0)
192 "Returns statistics about the unspent transaction output set.");
211 if (fHelp || params.size() < 2 || params.size() > 3)
213 "gettxout <txid> <n> [includemempool=true]\n"
214 "Returns details about an unspent transaction output.");
218 std::string strHash = params[0].
get_str();
220 int n = params[1].get_int();
221 bool fMempool =
true;
222 if (params.size() > 2)
223 fMempool = params[2].get_bool();
236 if (n<0 || (
unsigned int)n>=coins.
vout.size() || coins.
vout[n].IsNull())
240 if ((
unsigned int)coins.
nHeight == MEMPOOL_HEIGHT)
241 ret.push_back(
Pair(
"confirmations", 0));
247 ret.push_back(
Pair(
"scriptPubKey", o));
256 if (fHelp || params.size() > 2)
258 "verifychain [check level] [num blocks]\n"
259 "Verifies blockchain database.");
261 int nCheckLevel =
GetArg(
"-checklevel", 3);
262 int nCheckDepth =
GetArg(
"-checkblocks", 288);
263 if (params.size() > 0)
264 nCheckLevel = params[0].get_int();
265 if (params.size() > 1)
266 nCheckDepth = params[1].get_int();
268 return VerifyDB(nCheckLevel, nCheckDepth);
CBlockIndex * FindBlockByHeight(int nHeight)
Find a block by height in the currently-connected chain.
const_iterator begin() const
std::vector< CTxOut > vout
Value getblockcount(const Array ¶ms, bool fHelp)
int64 AmountFromValue(const Value &value)
bool VerifyDB(int nCheckLevel, int nCheckDepth)
Verify consistency of the block and coin databases.
void queryHashes(std::vector< uint256 > &vtxid)
Value gettxoutsetinfo(const Array ¶ms, bool fHelp)
Object blockToJSON(const CBlock &block, const CBlockIndex *blockindex)
Double ended buffer combining vector and stream-like interfaces.
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
Value getblock(const Array ¶ms, bool fHelp)
Object JSONRPCError(int code, const string &message)
bool GetStats(CCoinsStats &stats)
Value getdifficulty(const Array ¶ms, bool fHelp)
Config::Object_type Object
Value settxfee(const Array ¶ms, bool fHelp)
bool GetCoins(const uint256 &txid, CCoins &coins)
void ScriptPubKeyToJSON(const CScript &scriptPubKey, Object &out)
unsigned int GetSerializeSize(char a, int, int=0)
unsigned long long uint64_t
static const Value_impl null
bool GetCoins(const uint256 &txid, CCoins &coins)
Value getrawmempool(const Array ¶ms, bool fHelp)
const String_type & get_str() const
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
std::string GetHex() const
CBlockIndex * GetBestBlock()
std::string HexBits(unsigned int nBits)
void pruneSpent(const uint256 &hash, CCoins &coins)
Value ValueFromAmount(int64 amount)
The block chain is a tree shaped structure starting with the genesis block at the root...
Serialized script, used inside transaction inputs and outputs.
std::string ToString() const
double GetDifficulty(const CBlockIndex *blockindex)
int GetDepthInMainChain(CBlockIndex *&pindexRet) const
uint64 nTransactionOutputs
Value getbestblockhash(const Array ¶ms, bool fHelp)
std::vector< CTransaction > vtx
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Value getblockhash(const Array ¶ms, bool fHelp)
The basic transaction that is broadcasted on the network and contained in blocks. ...
Value gettxout(const Array ¶ms, bool fHelp)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Value verifychain(const Array ¶ms, bool fHelp)
bool ReadFromDisk(const CDiskBlockPos &pos)
CCoinsView that brings transactions from a memorypool into view.
map< uint256, CBlockIndex * > mapBlockIndex
uint256 GetBlockHash() const
A transaction with a merkle branch linking it to the block chain.
const_iterator end() const
const uint256 * phashBlock