Bitcoin for Mere Mortals: Blocks

Advertisement

Blocks are the data structures Bitcoin uses to permanently record data. This is common knowledge known by the initiated and in previous articles we’ve covered information related to these data structures. The block chain, isn’t really a chain at all. Well, logically there is a chain but it might not be what you first expect.

This article breaks down the structure of a block and provides insight to the moving parts “under the hood.” Hopefully, by the end, some of the underlying technology is to understand.

Bitcoin for Mere Mortals: Block Structure

That’s a block. In this image each cell represents one byte.

Magic Number
Bitcoin uses magic numbers to identify its network. Every Bitcoin-based cryptocurrency uses a magic number but the concept is not unique to Bitcoin. Magic numbers are used many ways and date back to the 70’s. In Unix, magic numbers were used to indicate format.

Where did it come from? In the source code we find:

// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };

Blocksize
Four bytes used to declare how large (in bytes) the block is. Currently this is capped at 1MB but the maximum 32 bit number is around 2 gigabytes.

Bitcoin for Mere Mortals: Block Header

Version
The version of your Bitcoin software. We all should probably upgrade

Previous Block Hash
This is just a number. However, this is where the logic of the ‘chain’ comes in to play. Because each new block contains the hash of block that came before it they are linked, mathematically. Since the hash is like a signature, unique to the block, it guarantees the blocks are sequential. Furthermore, the linkage creates structure, like a one-way linked list.

Block Hash
The current blocks hash. This is the value all the Bitcoin miner’s are trying to find. The first 8 bytes must be a lower number than the target, or it is not a valid block hash.

It’s important to note that this isn’t *set* in the sense that there is only one valid Block Hash every miner is searching for. Miner’s are searching for any hash that falls within a range of numbers defined by the target.

Time
Current Timestamp in seconds since the Unix Epoch Time. (1970-01-01T00:00 UTC)

Mining is a loop in which the miner’s hardware makes a ‘guess’ – we call it a hash. With each guess the miner may update their Time value. However Bitcoin rejects blocks with time values greater than two hours away from the network time.

Target
Bits representing the current difficulty.

Nonce
An incrementing value. The nonce is important in cryptography and for proof of work. There will be a future article describing how Proof of Work operates.

That’s it for the block header

Bitcoin for Mere Mortals: Transaction Lists

Transactions have been covered in another article. However, this is also a list that provides previous Bitcoin transactions owed to you as inputs and declares the new controller of those bitcoins with outputs.

Version
Version of the user’s software

In/Out Counter
Count of the inputs and outputs included in the transaction

List of Inputs/Outputs
Where the transfer of control over bitcoins actually takes place.

Lock Time
4 bytes representing a block height that must be achieved before this transaction can be mined. Does not guarantee the inputs will be unclaimed by the time that height is reached.