I am utilizing Bitcoin Core CLI to get block data:
.bitcoin-cli.exe getblockchaininfo
Amongst different issues, this returns two objects:
"time": 1713464903,
"mediantime": 1713461780,
I perceive the mediantime
is the median of the time
worth for the previous 11 blocks, and is used as a verify to make sure the miner used a legitimate timestamp worth for the time
of the block they only mined.
If I add 50 minutes to that mediantime
worth, is {that a} fairly good proxy for when essentially the most just lately mined block would have been mined? Intra block time is designed to be 10 minutes, however varies due to problem and the unpredictable nature of hashing, so in fact it will not be precise.
I am utilizing the next in Powershell to show essentially the most just lately mined block quantity, together with the time it was mined, and when it was anticipated to be mined, only for my very own edification:
[System.String]$block_chain_info = (.bitcoin-cli.exe --datadir=E:BitcoinCoreData 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 previous 11 blocks
$block_expected_time = $epoch.AddSeconds($bci.mediantime + (50 * 60));
Write-Output "Present Block Quantity is: $($bci.blocks)";
Write-Output "Block Time is: $($block_time.LocalDateTime.ToString{s})";
Write-Output "Block Anticipated Time is: $($block_expected_time.LocalDateTime.ToString{s})";
}
Else
{
"Couldn't receive block chain data from the Bitcoin Core CLI";
};
I am within the Central Commonplace Time timezone, so for the newest block, it exhibits:
Present Block Quantity is: 839816
Block Time is: 2024-04-18T13:46:27
Block Anticipated Time is: 2024-04-18T13:33:41
In case it issues, my bitcoin-cli --version
is:
Bitcoin Core RPC shopper model v27.0.0
Copyright (C) 2009-2024 The Bitcoin Core builders