Add branch IDs for current and next block to getblockchaininfo

Closes #2974.
This commit is contained in:
Jack Grigg 2018-02-21 21:02:09 +00:00
parent 71768555dd
commit ed9aa2b62a
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
2 changed files with 17 additions and 0 deletions

View File

@ -38,6 +38,9 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
#
# Currently at block 198. The next block to be mined 199 is a Sprout block
#
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['chaintip'], '00000000')
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['nextblock'], '00000000')
taddr0 = self.nodes[0].getnewaddress()
taddr2 = self.nodes[2].getnewaddress()
zaddr2 = self.nodes[2].z_getnewaddress()
@ -76,6 +79,8 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
#
# Currently at block 199. The next block to be mined 200 is an Overwinter block
#
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['chaintip'], '00000000')
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['nextblock'], '5ba81b19')
# Send taddr to taddr
tsendamount = Decimal('4.56')
@ -88,9 +93,12 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
myopid = self.nodes[0].z_sendmany(taddr0, recipients)
txid_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
# Mine the first Overwinter block
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['chaintip'], '5ba81b19')
assert_equal(self.nodes[0].getblockchaininfo()['consensus']['nextblock'], '5ba81b19')
# Verify balance
assert_equal(self.nodes[3].getbalance(), tsendamount)

View File

@ -726,6 +726,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
" \"status\": \"xxxx\", (string) status of upgrade\n"
" \"info\": \"xxxx\", (string) additional information about upgrade\n"
" }, ...\n"
" },\n"
" \"consensus\": { (object) branch IDs of the current and upcoming consensus rules\n"
" \"chaintip\": \"xxxxxxxx\", (string) branch ID used to validate the current chain tip\n"
" \"nextblock\": \"xxxxxxxx\" (string) branch ID that the next block will be validated under\n"
" }\n"
"}\n"
"\nExamples:\n"
@ -767,6 +771,11 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
}
obj.push_back(Pair("upgrades", upgrades));
UniValue consensus(UniValue::VOBJ);
consensus.push_back(Pair("chaintip", HexInt(CurrentEpochBranchId(tip->nHeight, consensusParams))));
consensus.push_back(Pair("nextblock", HexInt(CurrentEpochBranchId(tip->nHeight + 1, consensusParams))));
obj.push_back(Pair("consensus", consensus));
if (fPruneMode)
{
CBlockIndex *block = chainActive.Tip();