Skip to content

Commit

Permalink
Add info about ChainLocks to block and transaction RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jan 28, 2019
1 parent 135829d commit 3413ff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "evo/specialtx.h"
#include "evo/cbtx.h"

#include "llmq/quorums_chainlocks.h"

#include <stdint.h>

#include <univalue.h>
Expand Down Expand Up @@ -109,6 +111,9 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));

result.push_back(Pair("chainlock", llmq::chainLocksHandler->HasChainLock(blockindex->nHeight, blockindex->GetBlockHash())));

return result;
}

Expand Down Expand Up @@ -159,6 +164,9 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));

result.push_back(Pair("chainlock", llmq::chainLocksHandler->HasChainLock(blockindex->nHeight, blockindex->GetBlockHash())));

return result;
}

Expand Down
6 changes: 6 additions & 0 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "evo/specialtx.h"
#include "evo/providertx.h"
#include "evo/cbtx.h"

#include "llmq/quorums_chainlocks.h"
#include "llmq/quorums_commitment.h"

#include <stdint.h>
Expand Down Expand Up @@ -176,6 +178,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
}
}

bool chainLock = false;
if (!hashBlock.IsNull()) {
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
Expand All @@ -186,6 +189,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight));
entry.push_back(Pair("time", pindex->GetBlockTime()));
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));

chainLock = llmq::chainLocksHandler->HasChainLock(pindex->nHeight, pindex->GetBlockHash());
} else {
entry.push_back(Pair("height", -1));
entry.push_back(Pair("confirmations", 0));
Expand All @@ -194,6 +199,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
}
bool fLocked = instantsend.IsLockedInstantSendTransaction(txid);
entry.push_back(Pair("instantlock", fLocked));
entry.push_back(Pair("chainlock", chainLock));
}

UniValue getrawtransaction(const JSONRPCRequest& request)
Expand Down

0 comments on commit 3413ff9

Please sign in to comment.