Hey everyone,
Been diving into Bitcoin books lately. Got a few things bothering me though. How exactly is the timestamp on a mined block determined? Like, I assume when a miner finishes a block, they send the epoch time to their peers. But if that’s outside the block, won’t it be up for changes? So I guess it has to be in the block itself right?
Questions About How Bitcoin Network Works
6 replies 376 views
The timestamp is part of the block header, my dude. Once it’s there, it’s locked in. Miners can’t mess with it after the fact. The time needs to fall within a certain range, like being within the average of the last 11 blocks and not more than 2 hours ahead. No need for pinpoint accuracy.
What if I’m mining block 22, and I get it confirmed? I check the timestamp right after that and it’s 11:54:19. So I use that for my block 23 header and start mining.
If I spend 6 minutes finding my nonce, is the timestamp still 11:54:19?
To add to what mcdouglasx said,
Yeah, the miner sets the timestamp when they create the block. As long as it’s valid, it stays as part of the block data. The timestamp just has to be greater than the median time of the last 11 blocks and can be up to 2 hours ahead. So if you start at 11:54:19, that’s cool for 6 minutes.
Right, it’s definitely chosen by the miner. There are rules, like it can’t be less than the median time of previous blocks. And like 2 hours ahead is a no-go. But miners sometimes push those timestamps in test networks to see what they can get away with. The range keeps it practical.
Ahhh I get it now. I thought it was more exact for timing the blocks, kinda like syncing difficulty with mining power. I didn’t realize it was more flexible within a range.
Also, I used to think there was a super efficient method for picking combos in mining that everyone used, something set in stone. But now I’m wondering if that’s not the case. My Bitaxe gamma didn’t let me tweak anything.
In theory, nodes could be stricter about timestamps, but it wouldn’t help with past data. If a block has a timestamp, you can’t tell if it’s real or adjusted. You’d need to have been part of the network back then to trust it.
For instance, starting a new regtest node shows a timestamp like 1296688602. Just goes to show, timestamps can be tricky.