12 votes
Accepted

Why are block header bits necessary? (Valid difficulty is already implied by chain history)

They aren't really necessary. The reason that they are included can only be known by Satoshi, and AFAIK, he did not state why he chose to include nBits in the block header (or many other things that ...
Andrew Chow's user avatar
  • 68.6k
11 votes

Why don't the timestamps in the block chain always increase?

There is no requirement that blocks have a timestamp after the previous block. The only requirement is that the timestamp is greater than the median timestamp of the last 11 blocks. So this means that ...
Andrew Chow's user avatar
  • 68.6k
11 votes

What is a nonce?

Nonce is a 32 bit arbitrary random number that is typically used once. In Bitcoin's mining process, the goal is to find a hash below a target number which is calculated based on the difficulty. Proof ...
abeikverdi's user avatar
11 votes
Accepted

Unusual Version Number in Blocks

but I am going to take a slight guess that this has something to do with miner voting to show what the consensus is for a future change? No. There are currently no active consensus change proposals. ...
Andrew Chow's user avatar
  • 68.6k
9 votes
Accepted

How does Segwit prevent ASICBOOST?

There's 2 versions of ASICBOOST: Overt where miners use bits in the version number as extra nonce space Covert where miners "mine" merkle trees with 4 bytes collisions The overt version is very ...
alcio's user avatar
  • 1,274
9 votes

Calculate hash of block header

The version is wrong: I have 02000000 But the one that appears on the block is Version 0x20000000 Doing the formatting: 00000020 Calculating the hash of the block: from hashlib import ...
CamiloARG's user avatar
  • 177
8 votes
Accepted

What restrictions does the version field in the block header have?

nVersion is a 4-byte little-endian signed integer. Little-endianness means that the least significant byte is first. The order of bits in a byte remains the same. I’m aware of the following ...
Murch's user avatar
  • 73k
7 votes

Bitcoin mining: block structure

As an example of how to build a block header, here's a short Python program that calculates this block header's hash: #!/usr/bin/env python3 import urllib.request import json import binascii import ...
Nick ODell's user avatar
  • 29.3k
7 votes
Accepted

Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?

nBits cannot be changed at all. Its value must equal the (compact encoding of) the target value for that block, which is determined entirely by the predecessors of the block. In other words, if the ...
Pieter Wuille's user avatar
7 votes
Accepted

How strict are the Unix Epoch time validation rules?

How strict are the time validation rules? Very. If the next block is mined more than 2 hours after the current block, would this not stall the blockchain? No. It doesn't break the rule "Full ...
RedGrittyBrick's user avatar
7 votes
Accepted

What are the components of the raw block shown in this image?

The diagram is wrong The data in the gap between the two brackets is the count of transactions and most of the first coinbase transaction. The start/top of the second bracket is positioned incorrectly....
RedGrittyBrick's user avatar
6 votes
Accepted

At which point do blocks get validated in the mining process?

A block is checked in two places: First, it's checked before a miner starts working on it, and second, it's checked by every other node before accepting the block as valid.
Nick ODell's user avatar
  • 29.3k
6 votes
Accepted

How is mining difficulty defined (formula)?

The nBits field is basically scientific notation in base-256 (256 is 2^8). As an example, we take the one found on the Bitcoin.org Developer Reference: 0x181bc330 (Big-Endian order). This is split ...
meshcollider's user avatar
  • 11.8k
6 votes

Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?

nTime: blocks must have a higher timestamp than the median of the 11 previous blocks, and a lower timestamp than two hours in the future of the validating node's own clock. Assuming a regular block ...
Murch's user avatar
  • 73k
6 votes

How strict are the Unix Epoch time validation rules?

I think you have a misconception about what this clause means: Full nodes will not accept blocks with headers more than two hours in the future according to their clock. You appear to be ...
Douglas's user avatar
  • 161
5 votes
Accepted

how to convert blockchain to new version?

The issue here is with: (block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) Your block has version 2, but I assume the block you are trying to download is higher than ...
meshcollider's user avatar
  • 11.8k
5 votes
Accepted

Mining Block header bit reversing

Let's take a look at this block, because it only has one transaction (the coinbase): 000000000000000000eb2d0ed97a7b2cff7f1408417dca83908004beb6fd9b95 Let's grab the raw hex data: ...
meshcollider's user avatar
  • 11.8k
5 votes
Accepted

Merkle Root for 1-transaction block!

The merkle root of a block is the hash of all of the transactions. If there is one transaction, then the hash of all of the transactions is the hash of that one transaction. So the merkle root and the ...
Andrew Chow's user avatar
  • 68.6k
5 votes
Accepted

Are there any blockchain explorers that provide raw Tx data and block headers?

You can get this info from blockchain.info, by simply adding ?format=hexto the end of the relevant URL. For example, here is a recent block (height 509,244): https://blockchain.info/block/...
chytrik's user avatar
  • 18k
5 votes

Why are block header bits necessary? (Valid difficulty is already implied by chain history)

Directly committing to the nbits allows you to determine how much work was used to produce the header statelessly before looking for (or fetching) information about prior headers. This can help fend ...
G. Maxwell's user avatar
  • 7,696
5 votes
Accepted

If a lot of miners start at nonce 0, how are there no ties?

The block templates of two different miners will never overlap. Miners get paid by assigning the block reward in their mined blocks to themselves. Since each miner is trying to credit a different ...
Murch's user avatar
  • 73k
4 votes
Accepted

How is the mempool incorporated in the calculation of the block hash?

Every node in the network has a mempool. The mempool contains unconfirmed transactions. Each mempool may be slightly different as they constitute a subset of all unconfirmed transactions in the ...
Murch's user avatar
  • 73k
4 votes
Accepted

Why does bitcoin-cli return strange version numbers for blocks?

Great question. I had to do some research to find out. Currently version is actually 4 bytes. In the case of this block (and many other recent blocks, as it turns out) it's 01000020. This is little ...
Jimmy Song's user avatar
  • 7,749
4 votes

Why don't the timestamps in the block chain always increase?

There is a fair amount of leeway in the block timestamp. The timestamp for block N must be greater than the median network time, which is calculated as the median of the past 11 blocks, and also less ...
Raghav Sood's user avatar
4 votes

How often do miners recalculate the merkle root they're working on?

There are indeed many new transactions every second. The way miners deal with it is two-fold: If an appropriate proof-of-work is found on any merkle root, simply publish that block and any ...
Jimmy Song's user avatar
  • 7,749
4 votes
Accepted

Is the hash of the previous block included in the block header?

The block header is 80 bytes: Version number: 4 bytes Previous block header hash: 32 bytes Merkle root: 32 bytes Timestamp: 4 bytes Bits: 4 bytes Nonce: 4 bytes The merkle tree hashes all the ...
alcio's user avatar
  • 1,274
4 votes
Accepted

What is the difference between Root Hash and Block Hash?

First, all transactions are hashed along a Merkle tree. The root of that tree is the Merkle root. Then the block header is created with 6 fields: version number, the hash of the previous block, the ...
Pieter Wuille's user avatar
4 votes
Accepted

Significance of the "hash" field reported by the 'bitcoin-cli getblock' command

Is the "hash" field something that the 'bitcoin-cli' calculates and inserts in situ into the json for informational purpouses This is correct. The block contains all of the info necessary to compute ...
chytrik's user avatar
  • 18k
4 votes

Can a full node provide a bogus block bloomfilter to a Neutrino node?

They can lie to you about the filters, yes. However due to the filters being deterministic you can query other nodes for the hashes of their filters to gauge relative correctness. You can also use a ...
Claris's user avatar
  • 15.4k
4 votes

How to get block header hex?

I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is. It is a composite of values from the block - in brief, it is the concatenated binary (...
circulosmeos's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible