Transaction Data

A bitcoin transaction is just a bunch of data that describes the movement of bitcoins.

It takes in inputs, and creates new outputs.

Structure

01000000 01 7967a5185e907a25225574544c31f7b059c1a191d65b53dcc1554d339c4f9efc 01000000 6a 47304402206a2eb16b7b92051d0fa38c133e67684ed064effada1d7f925c842da401d4f22702201f196b10e6e4b4a9fff948e5c5d71ec5da53e90529c8dbd122bff2b1d21dc8a90121039b7bcd0824b9a9164f7ba098408e63e5b7e3cf90835cceb19868f54f8961a825 ffffffff 01 4baf210000000000 19 76a914db4d1141d0048b1ed15839d0b7a4c488cd368b0e88ac 00000000

Transaction: c1b4e695098210a31fe02abffe9005cffc051bbe86ff33e173155bcbdc5821e3

Fields

Field Data Size Description Version 01000000 ⟲ 4 bytes Which version of transaction data structure we’re using. Input Count 01 Variable Indicates the upcoming number of inputs. Input(s) Field Data Size Description TXID 796…efc ⟲ 32 bytes Refer to an existing transaction. VOUT 01000000 ⟲ 4 bytes Select one of its outputs. ScriptSig Size 6a Variable Indicates the upcoming size of the unlocking code. ScriptSig 473…825 A script that unlocks the input. Sequence ffffffff ⟲ 4 bytes Output Count 01 Variable Indicates the upcoming number of outputs. Output(s) Field Data Size Description Value 4baf210000000000 ⟲ 8 bytes The value of the output in satoshis. ScriptPubKey Size 19 Variable Indicates the upcoming size of the locking code. ScriptPubKey 76a9…88ac A script that locks the output. Locktime 00000000 ⟲ 4 bytes Set a minimum block height or Unix time that this transaction can be included in.

All of the data in a transaction is in hexadecimal.

The following icon indicates that the data is in reverse byte order: ⟲

Diagram

A transaction is basically a series of inputs and a series of outputs.

In further detail; the transaction data tells you how to unlock existing packages of bitcoins (from previous transactions), and how to lock them up again in to new packages.

Notes

A raw transaction is sometimes called a “serialized transaction”, because it’s just a bunch of individual pieces of data zipped up in to one string of data.

Field Sizes Nodes on the bitcoin network expect each field to be a certain length. This structured format allows them to run through the transaction data and figure out where each field begins and ends. That’s why even though the version number is 1, it’s stored as 01000000 because a bitcoin node expects a field that is 4 bytes in size. If you double the number of bytes, it will give you the number of characters in that field. The inputcount (and signatures ) and outputcount (and lockingscripts ) can vary in length, which is why special VarInt fields are used to specify their upcoming sizes.