banner

I’m using Bitcoin Core CLI to get block info:

.\bitcoin-cli.exe getblockchaininfo

Among other things, this returns two items:

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

I understand the mediantime is the median of the time value for the past 11 blocks, and is used as a check to ensure the miner used a valid timestamp value for the time of the block they just mined.

If I add 50 minutes to that mediantime value, is that a reasonably good proxy for when the most recently mined block would have been mined? Intra block time is designed to be 10 minutes, but varies because of difficulty and the unpredictable nature of hashing, so of course it won’t be exact.

I’m using the following in Powershell to display the most recently mined block number, along with the time it was mined, and when it was expected to be mined, just for my own edification:

[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.ToString{s})";
    Write-Output "Block Expected Time is:     $($block_expected_time.LocalDateTime.ToString{s})";
}
Else
{
    "Could not obtain block chain info from the Bitcoin Core CLI";
};

I’m in the Central Standard Time timezone, so for the most recent block, it shows:

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 matters, my bitcoin-cli --version is:

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

banner

Converter

Source: CurrencyRate
Top Selling Multipurpose WP Theme

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

banner

Leave a Comment

Layer 1
Your Crypto & Blockchain Beacon

CryptoInsightful

Welcome to CryptoInsightful.com, your trusted source for in-depth analysis, news, and insights into the world of cryptocurrencies, blockchain technology, NFTs (Non-Fungible Tokens), and cybersecurity. Our mission is to empower you with the knowledge and understanding you need to navigate the rapidly evolving landscape of digital assets and emerging technologies.