Bitcoin Data Model¶
This is a high-level overview of Bitcoin’s data model. For the full details, refer to https://bitcoin.org/en/developer-reference.
The 80 bytes block header hash encodes the following information:
||i32||The block version to follow.|
||char||The double sha256 hash of the previous block header.|
||char||The double sha256 hash of the Merkle root of all transaction hashes in this block.|
||u32||The block timestamp included by the miner.|
||u32||The target difficulty threshold, see also the Bitcoin documentation.|
||u32||The nonce chosen by the miner to meet the target difficulty threshold.|
A transaction is broadcasted in a serialized byte format (also called raw format). It consists of a variable size of bytes and has the following format.
||i32||Transaction version number.|
||uint||Number of transaction inputs.|
||uint||The number of transaction outputs.|
||u32||A Unix timestamp OR block number.|
Bitcoin uses the term “CompactSize Unsigned Integers” to refer to variable-length integers, which are used to indicate the number of bytes representing transaction inputs and outputs. See the Developer Reference for more details.
Bitcoin’s UTXO model requires a new transaction to spend at least one existing and unspent transaction output as a transaction input. The
txIn type consists of the following bytes. See the reference for further details.
||outpoint||The output to be spent consisting of the transaction hash (32 bytes) and the output index (4 bytes).|
||uint||Number of bytes in the signature script (max 10,000 bytes).|
||char||The script satisfying the output’s script.|
||u32||Sequence number (default