Browse Source

RPC: add getbestblockhash, to return tip of best chain

0.8
Jeff Garzik 11 years ago committed by Warren Togami
parent
commit
8687a0ebbc
  1. 1
      src/bitcoinrpc.cpp
  2. 1
      src/bitcoinrpc.h
  3. 9
      src/rpcblockchain.cpp

1
src/bitcoinrpc.cpp

@ -202,6 +202,7 @@ static const CRPCCommand vRPCCommands[] =
{ "help", &help, true, true }, { "help", &help, true, true },
{ "stop", &stop, true, true }, { "stop", &stop, true, true },
{ "getblockcount", &getblockcount, true, false }, { "getblockcount", &getblockcount, true, false },
{ "getbestblockhash", &getbestblockhash, true, false },
{ "getconnectioncount", &getconnectioncount, true, false }, { "getconnectioncount", &getconnectioncount, true, false },
{ "getpeerinfo", &getpeerinfo, true, false }, { "getpeerinfo", &getpeerinfo, true, false },
{ "addnode", &addnode, true, true }, { "addnode", &addnode, true, true },

1
src/bitcoinrpc.h

@ -192,6 +192,7 @@ extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, b
extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getblockcount(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 getbestblockhash(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value setmininput(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value setmininput(const json_spirit::Array& params, bool fHelp);

9
src/rpcblockchain.cpp

@ -81,6 +81,15 @@ Value getblockcount(const Array& params, bool fHelp)
return nBestHeight; return nBestHeight;
} }
Value getbestblockhash(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getbestblockhash\n"
"Returns the hash of the best (tip) block in the longest block chain.");
return hashBestChain.GetHex();
}
Value getdifficulty(const Array& params, bool fHelp) Value getdifficulty(const Array& params, bool fHelp)
{ {

Loading…
Cancel
Save