Marc Steiner
Marc Steiner

Description of Bitcoin Blocks and Transactions

Overview about Bitcoin Transaction

Following description shows a deep inside into how Bitcoin blocks and transactions are looking on a byte-level.

The level of detail is something around six to seven on a scale from 0–10 (10 = Bitcoin hardcore developer). The target audience is a person who wants to understand the technical aspects of a block and transactions.

You should be familiar with Inputs, Outputs and Script language. Maybe this helps: https://medium.com/@marc_steiner/technical-summary-about-a-bitcoin-transaction-in-one-picture-1455e1812227

There are similar descriptions out there, but I have tried to reduce all the noise and come straight to the point.

I use following Block as example 0000000000000000000bd1dcc67100bddc69e85426a2d9b298f15f6fddc2f4d7, with this transaction 69DF7FDCD5AB9BA1CB3FF573731ACF6ED37CC9A1CB92C6ED7FFCABA92605E49B inside the block.

First, we have to understand what is inside of a Bitcoin block. There are two main parts; The block header and the transactions list.

overview-bitcoin-block-and-transaction-and-what-is-inside-of-the-block
Overview about a Bitcoin block and what is inside

Block Header

The block header contains all of the relevant information to verify a block. The hash of the header represents the information of a block without transactions. Simplified Payment Verification devices (SPV) just save this 80 byte because of limited storage capacity. (Detailed description: LinkLink)

Transaction list

Now, we will have a closer look into the structure of one transaction. There are a lot of “byte-information” inside a single transaction. The same concept here; Just the SHA-256 hash of the full transaction information is stored in the Bitcoin block as the following pictures shows.

how-does-a-raw-hex-bitcoin-transaction-is-hashed-into-a-block
Method from a raw Bitcoin HEX transaction into a block

It is now interesting to understand how the byte structure of this transaction look like. A Bitcoin transaction based on the concept of inputs (“crawling” the Bitcoin to spend from a previous transaction) and outputs (how many Bitcoin will be sent to the next address). On byte level it looks like this:

detailed-structure-of-a-raw-hex-bitcoin-transaction
Detailed analysis of a raw Bitcoin transaction

Description of Bitcoin Inputs

Transaction version (fix 4 byte): 
Identifies the protocol version being used by the node, currently “1”. (Detailed description: Link)

Input Count / Number of inputs (1–9 byte):
Indicates the upcoming number of inputs in this transaction.(Detailed description: Link)

Previous transaction hash (fix 32 byte):
Link to an existing transaction in the previous parent block (last block of Blockchain) so that the node knows to which block the new block must be linked. (Detailed description: Link)

Output index of previous transaction outputs (fix 4 byte):
Every output has a index number. The first output is index “0”. The index number shows which output (UTXO) from a previous transaction will be spent in this new transaction. (Detailed description: LinkLink)

Input script length (1–9 bytes):
Defines how long (number of bytes) the following input script (unlocking code) is.

ScriptSig operation:
Defines what the node has to do. OP_PUSHDATA, pushes the defined number of bytes on the stack. (Detailed description: LinkLink)

ScriptSig data (many bytes):
Unlocking script, that unlocks your Bitcoin which will be spent (is part of each input script). The script checks if the conditions are full-filled to spend the unspent transaction output (UTXO). Or in more easy words: Unlocking code checks, if your are allowed to spend the Bitcoins you want to send.(Detailed description: LinkLink)

Input sequence number (fix 4 byte):
Normally 0xFFFFFFFF. Irrelevant unless transaction’s locktime is >0. A number intended to allow unconfirmed time-locked transactions to be updated before being finalized; currently not used except to disable locktime in a transaction. (Detailed description: Link)

Description of Bitcoin Outputs

Number of outputs (1–9 bytes):
How many outputs are following and will be spent (upcoming number of outputs).

Output value (fix 8 byte):
Specifies how many Bitcoin in Satoshi (BTC/ 10⁸) will be transfered to the next address.(Detailed description: Link)

Output Script length (1–9 bytes):
Defines how long (number of bytes) the following output script (locking code) is: ScriptPubKey Operation+ ScriptSig data.(Detailed description: Link)

ScriptPubKey operation:
Defines the steps, what the node has to do next (script).

ScriptPubKey data (many bytes):
Locking script, that defines the conditions when the outputs (Bitcoins) could be spent in a next transaction or more technical: It is a short script that explains what conditions must be met to claim ownership of bitcoins. The name “ScriptPubKey” comes from the fact, that this script needs a publicKey .(Detailed description: LinkLinkLinkLink)

Transaction lock time (4 byte):
Defines the earliest time that a transaction is valid (or minimum block height) and can be relayed on the network or added to the blockchain. (Detailed description: Link)

Note: bytes are little endian

Here you find a similar article on Medium with beautiful graphics.

Newsletter

Für weitere wertvolle Informationen rund um das Thema Bitcoin melde dich jetzt für meinen Newsletter an.

Hat dir der Artikel gefallen? Unterstütze mich mit Bitcoin-Lightning. Danke!

sats
Marc Steiner
Marc Steiner

Bitcoin-Berater & Digital-Experte

Weitere interessante Artikel

bitcoin_einstieg_in_10_schritten

Bitcoin Einstieg

Du suchst einen einfachen, schnellen Bitcoin Einstieg? Unten findest du meine Top 10 Schritte, mit denen du dich zügig in das Thema

Wie viele Bitcoins gibt es aktuell?

Um es vorwegzunehmen: Die Antwort auf die Frage «Wie viele Bitcoins gibt es?» lautet zum Zeitpunkt dieses Artikels 18’470’948.37854892 Bitcoins. Wenn du

Kontakt

Du willst wissen wie Bitcoin funktioniert, mit mir ein Wallet aufsetzen oder generell über digitale Themen reden?

Buch Veröffentlichung: 

verschoben auf Mai 2020

Ca. 130 Seiten – 19.90€/22CHF 

Willst du den Release nicht verpassen? Trage deine E-Mail Adresse ein oder folge mir auf Twitter und LinkedIn.