Let’s understand the mechanics of a real bitcoin transaction. We’ll use the image above as a reference.
If you were to cut open a typical bitcoin transaction, you’d end up with three major pieces: the header, the input(s), and the output(s). Let’s briefly look at the fields available to us in these sections, as they’ll be important for discussion. Note that these are the fields that are in a so-called raw transaction. Raw transactions are broadcast between peers when a transaction is created.
hash: The hash over this entire transaction. Bitcoin generally uses hash values, both a pointer and a means to check the integrity of a piece of data. We’ll look at this more in the next section.
ver: The version number that should be used to verify this block. The latest version was introduced in a soft fork that became active in December 2015.
vin_sz: The number of inputs to this transaction. Similarly, vout_sz counts the number of outputs.
lock_time: We’ll look at this more in later articles, but this basically describes the earliest time a block can be added to the blockchain. It is either the block height or a unix timestamp.
previous output hash: This is a hash pointer to a previous unspent transaction output (UTXO). Essentially, this is money that belongs to you that you are about to spend in this transaction.
n: An index into the list of outputs of the previous transaction. This is the actual output that you are spending.
scriptSig: This is a spending script that proves that the creator of this transaction has permission to spend the money referenced by 1. and 2.
value: The amount of Satoshi being spent (1 BTC = 100,000,000 Satoshi).
scriptPubKey: The second of two scripts provided in a bitcoin transaction, which points to a recipient’s hashed public key. More on this in the last section of this article.
The amount lists the amount of cryptocurrency that is being transferred. Transactions are ultimately measured in “satoshis,” which is equal to 100,000,000 bitcoins.