In very simple terms, a Bitcoin transaction (TX), is the basic data structure supporting the transfer of value from one BTC address to another.
Bitcoin transactions are structured such that:
Transaction inputs (TxIn) map former outputs to new outputs.
The input contains code that solves a previous output (proves whoever is moving the BTC has the private key) and therefore unlocks the output. The recipient of the new output will then create his own transactions by unlocking the new outputs by signing a new input.
The new output, until spent, becomes part of the “balance” of the recipient. Until an input exists for an output, the output is called unspent (UTXO).
The other “half” of Bitcoin transactions is made up of outputs (TxOut).
In fact, outputs are the first half, since a special output that doesn’t have a previous input is the first information stored in every block. This special input-less TX is called the coinbase and it only contains a single output.
The Bitcoin chicken and egg scenario, therefore, begins with an output. The first ever data recorded in the Bitcoin Genesis Block is the now world famous TxOut containing Satoshi Nakamoto’s “Chancellor on the brink […]” easter egg.
What we know as a “Bitcoin balance” is, in fact, the sum of unspent outputs (UTXO’s) sent to a given private key.
Your wallet software will scan the entire blockchain looking for outputs that match one of your wallet addresses. When no input matches the found output, that output is considered unspent and the satoshi amount contained in it is added to your balance.
The Bitcoin blockchain is one large data structure whose sole purpose is to correctly track unspent outputs.
Inputs link former outputs to new outputs. The inputs simply bridge outputs one to the next – the real accounting is done using outputs.
To explore the Bitcoin blockchain using Crypto.BI Toolbox, you may query the cb_tx_out
table and cross reference it (left join) with the cb_tx_in
table.
Using the left join operation, any outputs having a NULL
right hand side will be unspent TX’s.