diff options
Diffstat (limited to 'src/rpc/blockchain.cpp')
| -rw-r--r-- | src/rpc/blockchain.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 948553d9a..3309a9701 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -80,6 +80,42 @@ double GetDifficulty(const CBlockIndex* blockindex) return dDiff; } +UniValue AuxpowToJSON(const CAuxPow& auxpow) +{ + UniValue result(UniValue::VOBJ); + + { + UniValue tx(UniValue::VOBJ); + tx.pushKV("hex", EncodeHexTx(*auxpow.coinbaseTx.tx)); + TxToUniv(*auxpow.coinbaseTx.tx, auxpow.parentBlock.GetHash(), tx); + result.pushKV("tx", tx); + } + + result.pushKV("index", auxpow.coinbaseTx.nIndex); + result.pushKV("chainindex", auxpow.nChainIndex); + + { + UniValue branch(UniValue::VARR); + for (const auto& node : auxpow.coinbaseTx.vMerkleBranch) + branch.push_back(node.GetHex()); + result.pushKV("merklebranch", branch); + } + + { + UniValue branch(UniValue::VARR); + for (const auto& node : auxpow.vChainMerkleBranch) + branch.push_back(node.GetHex()); + result.pushKV("chainmerklebranch", branch); + } + + CDataStream ssParent(SER_NETWORK, PROTOCOL_VERSION); + ssParent << auxpow.parentBlock; + const std::string strHex = HexStr(ssParent.begin(), ssParent.end()); + result.pushKV("parentblock", strHex); + + return result; +} + UniValue blockheaderToJSON(const CBlockIndex* blockindex) { AssertLockHeld(cs_main); @@ -148,6 +184,9 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.pushKV("chainwork", blockindex->nChainWork.GetHex()); result.pushKV("nTx", (uint64_t)blockindex->nTx); + if (block.auxpow) + result.pushKV("auxpow", AuxpowToJSON(*block.auxpow)); + if (blockindex->pprev) result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()); CBlockIndex *pnext = chainActive.Next(blockindex); @@ -729,7 +768,7 @@ static UniValue getblockheader(const JSONRPCRequest& request) if (!fVerbose) { CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); - ssBlock << pblockindex->GetBlockHeader(); + ssBlock << pblockindex->GetBlockHeader(Params().GetConsensus()); std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); return strHex; } @@ -1270,7 +1309,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); - for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { + for (int pos = Consensus::DEPLOYMENT_TESTDUMMY + 1; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast<Consensus::DeploymentPos>(pos)); } obj.pushKV("softforks", softforks); |