diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2013-07-10 08:49:50 -0700 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2013-07-10 08:49:50 -0700 |
commit | 3b837d5679af0c54ef2cef233cf42c09cdc50926 (patch) | |
tree | 0781d8fe4e04dce855797b98d41a970eed740c61 | |
parent | 61186321dfe85769578c04dbb82ddd3b0d4266a2 (diff) | |
parent | 091aa8dae9b7345a1cd81e2733766463dfbf4b82 (diff) |
Merge pull request #2812 from jgarzik/rpcbestblock
RPC: add getbestblockhash, to return tip of best chain
-rw-r--r-- | src/bitcoinrpc.cpp | 1 | ||||
-rw-r--r-- | src/bitcoinrpc.h | 1 | ||||
-rw-r--r-- | src/rpcblockchain.cpp | 9 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 5908126200..11fac42213 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -195,6 +195,7 @@ static const CRPCCommand vRPCCommands[] = { "help", &help, true, true }, { "stop", &stop, true, true }, { "getblockcount", &getblockcount, true, false }, + { "getbestblockhash", &getbestblockhash, true, false }, { "getconnectioncount", &getconnectioncount, true, false }, { "getpeerinfo", &getpeerinfo, true, false }, { "addnode", &addnode, true, true }, diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index 247c47adf9..4d5599be84 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -201,6 +201,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 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 settxfee(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getrawmempool(const json_spirit::Array& params, bool fHelp); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 3c24016fe3..edaa732225 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -82,6 +82,15 @@ Value getblockcount(const Array& params, bool fHelp) 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) { |