Skip to content

Commit

Permalink
Add getbestblockhash
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranz5 committed May 20, 2014
1 parent 99a22a9 commit 4884b69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ static const CRPCCommand vRPCCommands[] =
// ------------------------ ----------------------- ------ --------
{ "help", &help, true, true },
{ "stop", &stop, true, true },
{ "getbestblockhash", &getbestblockhash, true, false },
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false },
Expand Down
1 change: 1 addition & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ extern json_spirit::Value decoderawtransaction(const json_spirit::Array& params,
extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp);

extern json_spirit::Value getbestblockhash(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp);
Expand Down
9 changes: 9 additions & 0 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
return result;
}

Value getbestblockhash(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getbestblockhash\n"
"Returns the hash of the best block in the longest block chain.");

return hashBestChain.GetHex();
}

Value getblockcount(const Array& params, bool fHelp)
{
Expand Down

0 comments on commit 4884b69

Please sign in to comment.