Skip to content

Commit

Permalink
Merge pull request #31 from wakiyamap/add_rpc_for_blockbook
Browse files Browse the repository at this point in the history
Add rpc for blockbook
  • Loading branch information
namuyan authored May 18, 2019
2 parents 9ff2496 + ec0cbe1 commit ef50cc7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,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 },
{ "getdifficulty", &getdifficulty, 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 @@ -208,6 +208,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);
Expand Down
14 changes: 13 additions & 1 deletion src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
{
Object entry;

entry.push_back(Pair("txid", tx.GetHash().GetHex()));
//entry.push_back(Pair("txid", tx.GetHash().GetHex()));
TxToJSON(tx, 0, entry);

txinfo.push_back(entry);
Expand Down Expand Up @@ -234,6 +234,18 @@ Value getblockbynumber(const Array& params, bool fHelp)
return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
}

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

CBlockIndex* pblockindex = FindBlockByHeight(nBestHeight);
return pblockindex->phashBlock->GetHex();
}


// ppcoin: get information of sync-checkpoint
Value getcheckpoint(const Array& params, bool fHelp)
{
Expand Down

0 comments on commit ef50cc7

Please # to comment.