mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-07 10:27:47 -05:00
rpc: add target and bits to getblockchaininfo
This commit is contained in:
parent
baa504fdfa
commit
f153f57acc
2 changed files with 9 additions and 0 deletions
|
@ -1299,6 +1299,8 @@ RPCHelpMan getblockchaininfo()
|
|||
{RPCResult::Type::NUM, "blocks", "the height of the most-work fully-validated chain. The genesis block has height 0"},
|
||||
{RPCResult::Type::NUM, "headers", "the current number of headers we have validated"},
|
||||
{RPCResult::Type::STR, "bestblockhash", "the hash of the currently best block"},
|
||||
{RPCResult::Type::STR_HEX, "bits", "nBits: compact representation of the block difficulty target"},
|
||||
{RPCResult::Type::STR_HEX, "target", "The difficulty target"},
|
||||
{RPCResult::Type::NUM, "difficulty", "the current difficulty"},
|
||||
{RPCResult::Type::NUM_TIME, "time", "The block time expressed in " + UNIX_EPOCH_TIME},
|
||||
{RPCResult::Type::NUM_TIME, "mediantime", "The median block time expressed in " + UNIX_EPOCH_TIME},
|
||||
|
@ -1337,6 +1339,8 @@ RPCHelpMan getblockchaininfo()
|
|||
obj.pushKV("blocks", height);
|
||||
obj.pushKV("headers", chainman.m_best_header ? chainman.m_best_header->nHeight : -1);
|
||||
obj.pushKV("bestblockhash", tip.GetBlockHash().GetHex());
|
||||
obj.pushKV("bits", strprintf("%08x", tip.nBits));
|
||||
obj.pushKV("target", GetTarget(tip, chainman.GetConsensus().powLimit).GetHex());
|
||||
obj.pushKV("difficulty", GetDifficulty(tip));
|
||||
obj.pushKV("time", tip.GetBlockTime());
|
||||
obj.pushKV("mediantime", tip.GetMedianTimePast());
|
||||
|
|
|
@ -133,6 +133,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
|
||||
keys = [
|
||||
'bestblockhash',
|
||||
'bits',
|
||||
'blocks',
|
||||
'chain',
|
||||
'chainwork',
|
||||
|
@ -142,6 +143,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
'mediantime',
|
||||
'pruned',
|
||||
'size_on_disk',
|
||||
'target',
|
||||
'time',
|
||||
'verificationprogress',
|
||||
'warnings',
|
||||
|
@ -198,6 +200,9 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
assert_equal(res['prune_target_size'], 576716800)
|
||||
assert_greater_than(res['size_on_disk'], 0)
|
||||
|
||||
assert_equal(res['bits'], nbits_str(REGTEST_N_BITS))
|
||||
assert_equal(res['target'], target_str(REGTEST_TARGET))
|
||||
|
||||
def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash, status_next):
|
||||
assert height >= 144 and height <= 287
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue