@@ -71,6 +71,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
71
71
result.push_back (Pair (" version" , blockindex->nVersion ));
72
72
result.push_back (Pair (" merkleroot" , blockindex->hashMerkleRoot .GetHex ()));
73
73
result.push_back (Pair (" time" , (int64_t )blockindex->nTime ));
74
+ result.push_back (Pair (" mediantime" , (int64_t )blockindex->GetMedianTimePast ()));
74
75
result.push_back (Pair (" nonce" , (uint64_t )blockindex->nNonce ));
75
76
result.push_back (Pair (" bits" , strprintf (" %08x" , blockindex->nBits )));
76
77
result.push_back (Pair (" difficulty" , GetDifficulty (blockindex)));
@@ -111,6 +112,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
111
112
}
112
113
result.push_back (Pair (" tx" , txs));
113
114
result.push_back (Pair (" time" , block.GetBlockTime ()));
115
+ result.push_back (Pair (" mediantime" , (int64_t )blockindex->GetMedianTimePast ()));
114
116
result.push_back (Pair (" nonce" , (uint64_t )block.nNonce ));
115
117
result.push_back (Pair (" bits" , strprintf (" %08x" , block.nBits )));
116
118
result.push_back (Pair (" difficulty" , GetDifficulty (blockindex)));
@@ -313,6 +315,7 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
313
315
" \" version\" : n, (numeric) The block version\n "
314
316
" \" merkleroot\" : \" xxxx\" , (string) The merkle root\n "
315
317
" \" time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n "
318
+ " \" mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n "
316
319
" \" nonce\" : n, (numeric) The nonce\n "
317
320
" \" bits\" : \" 1d00ffff\" , (string) The bits\n "
318
321
" \" difficulty\" : x.xxx, (numeric) The difficulty\n "
@@ -374,6 +377,7 @@ UniValue getblock(const UniValue& params, bool fHelp)
374
377
" ,...\n "
375
378
" ],\n "
376
379
" \" time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n "
380
+ " \" mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n "
377
381
" \" nonce\" : n, (numeric) The nonce\n "
378
382
" \" bits\" : \" 1d00ffff\" , (string) The bits\n "
379
383
" \" difficulty\" : x.xxx, (numeric) The difficulty\n "
@@ -608,6 +612,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
608
612
" \" headers\" : xxxxxx, (numeric) the current number of headers we have validated\n "
609
613
" \" bestblockhash\" : \" ...\" , (string) the hash of the currently best block\n "
610
614
" \" difficulty\" : xxxxxx, (numeric) the current difficulty\n "
615
+ " \" mediantime\" : xxxxxx, (numeric) median time for the current best block\n "
611
616
" \" verificationprogress\" : xxxx, (numeric) estimate of verification progress [0..1]\n "
612
617
" \" chainwork\" : \" xxxx\" (string) total amount of work in active chain, in hexadecimal\n "
613
618
" \" pruned\" : xx, (boolean) if the blocks are subject to pruning\n "
@@ -639,6 +644,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
639
644
obj.push_back (Pair (" headers" , pindexBestHeader ? pindexBestHeader->nHeight : -1 ));
640
645
obj.push_back (Pair (" bestblockhash" , chainActive.Tip ()->GetBlockHash ().GetHex ()));
641
646
obj.push_back (Pair (" difficulty" , (double )GetDifficulty ()));
647
+ obj.push_back (Pair (" mediantime" , (int64_t )chainActive.Tip ()->GetMedianTimePast ()));
642
648
obj.push_back (Pair (" verificationprogress" , Checkpoints::GuessVerificationProgress (Params ().Checkpoints (), chainActive.Tip ())));
643
649
obj.push_back (Pair (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ()));
644
650
obj.push_back (Pair (" pruned" , fPruneMode ));
0 commit comments