Skip to content

Commit 6531f17

Browse files
committed
Add mediantime field to getblock and getblockheader
1 parent 7259769 commit 6531f17

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/rpcblockchain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
7171
result.push_back(Pair("version", blockindex->nVersion));
7272
result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex()));
7373
result.push_back(Pair("time", (int64_t)blockindex->nTime));
74+
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast()));
7475
result.push_back(Pair("nonce", (uint64_t)blockindex->nNonce));
7576
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits)));
7677
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
@@ -111,6 +112,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
111112
}
112113
result.push_back(Pair("tx", txs));
113114
result.push_back(Pair("time", block.GetBlockTime()));
115+
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast()));
114116
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
115117
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
116118
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
@@ -313,6 +315,7 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
313315
" \"version\" : n, (numeric) The block version\n"
314316
" \"merkleroot\" : \"xxxx\", (string) The merkle root\n"
315317
" \"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"
316319
" \"nonce\" : n, (numeric) The nonce\n"
317320
" \"bits\" : \"1d00ffff\", (string) The bits\n"
318321
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
@@ -374,6 +377,7 @@ UniValue getblock(const UniValue& params, bool fHelp)
374377
" ,...\n"
375378
" ],\n"
376379
" \"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"
377381
" \"nonce\" : n, (numeric) The nonce\n"
378382
" \"bits\" : \"1d00ffff\", (string) The bits\n"
379383
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"

0 commit comments

Comments
 (0)