Bitcoin

bitcoin core – Can the median time be used as a proxy for the estimated time of the most recently mined block?

I am using Bitcoin Core CLI to get block information.

.\bitcoin-cli.exe getblockchaininfo

Among other things, this returns two items:

  "time": 1713464903,
  "mediantime": 1713461780,

I understand mediantime is the median of time This is the value from the last 11 blocks and is used to check if the miner used a valid timestamp value for that block. time of the block they just mined.

Add 50 minutes to that mediantime Is value a reasonably good proxy for when the most recently mined block was mined? The intra-block time is designed to be 10 minutes, but of course this is not exact as it can vary due to the difficulty and unpredictable nature of hashing.

I use the following in Powershell to display the most recently mined block number, the mining time, and the estimated mining time.

(System.String)$block_chain_info = (.\bitcoin-cli.exe --datadir=E:\BitcoinCore\Data getblockchaininfo);
If ($block_chain_info -ne $null)

    (System.Object)$bci = (ConvertFrom-Json $block_chain_info -ErrorAction SilentlyContinue);
    $epoch = New-Object DateTimeOffset(1970,1,1,0,0,0,0);
    $block_time = $epoch.AddSeconds($bci.time);
    #mediantime is the median time of the past 11 blocks
    $block_expected_time = $epoch.AddSeconds($bci.mediantime + (50 * 60));
    Write-Output "Current Block Number is:    $($bci.blocks)";
    Write-Output "Block Time is:              $($block_time.LocalDateTime.ToStrings)";
    Write-Output "Block Expected Time is:     $($block_expected_time.LocalDateTime.ToStrings)";

Else

    "Could not obtain block chain info from the Bitcoin Core CLI";
;

I’m in the Central Standard Time time zone, so this is what I see for the most recent block:

Current Block Number is:    839816
Block Time is:              2024-04-18T13:46:27
Block Expected Time is:     2024-04-18T13:33:41

In case it is important bitcoin-cli --version am:

Bitcoin Core RPC client version v27.0.0
Copyright (C) 2009-2024 The Bitcoin Core developers

Related Articles

Back to top button