Bitcoin Tutorials - Herong's Tutorial Notes - v1.07, by Herong Yang
Data Structure of Bitcoin Raw Transaction Format
This section describes the data structure of a Bitcoin raw transaction format.
A Bitcoin raw transaction format has the following data structure:
Bytes Name Description 4 version Transaction version number; currently version 1. Programs creating transactions using newer consensus rules may use higher version numbers. Varies tx_in_count Number of inputs in this transaction. Varies tx_in Transaction inputs. Varies tx_out_count Number of outputs in this transaction. Varies tx_out Transaction outputs. 4 lock_time A time (Unix epoch time) or block number.
The "tx_in" represents a list of transaction inputs in a non-coinbase transaction. See next tutorial on the "tx_in" structure of a coinbase transaction. Each transaction input has the following data structure:
Bytes Name Description 36 previous_output The previous outpoint being spent, consisting of a 32-byte TXID and a 4-byte output index number (vout). Varies script bytes The number of bytes in the signature script. Varies signature script A script-language script which satisfies the conditions placed in the outpoint’s pubkey script. Should only contain data pushes; see the signature script modification warning. 4 sequence Sequence number. Default for Bitcoin Core and almost all other programs is 0xffffffff.
The "tx_out" represents a list of transaction outputs. Each transaction output has the following data structure:
Bytes Name Description 8 value Number of satoshis to spend. May be zero; the sum of all outputs may not exceed the sum of satoshis previously spent to the outpoints provided in the input section. 1+ pk_script bytes Number of bytes in the pubkey script. Varies pk_script Defines the conditions which must be satisfied to spend this output.
Table of Contents
►Bitcoin Transaction Data Structure
Data Properties of Bitcoin Transaction
►Data Structure of Bitcoin Raw Transaction Format
Decode Bitcoin Raw Transaction Format