Ch.9: Something on Transaction UTXO

Khor Aik Cheow, PhD
4 min readJun 25, 2020

--

Different blockchain network structures its transaction differently. Bitcoin has adopted the UTXO(Unspent Transaction Output)-based transaction model, while Ethereum (another blockchain network) has adopted the Account-based transaction model. In this article I’ll only talk about UTXO model.

Under the UTXO model, each bitcoin transaction is made up of one or more inputs and outputs. Each input is linked to the output of the previous transaction. And each output is linked to the input of the subsequent transaction.

The only bitcoin transaction that do not have an input is the first transaction in every blockchain block. The first transaction is called ‘coinbase transaction’ or ‘generation transaction’. Don’t confuse it with the ‘Coinbase’ digital currency exchange company (denoted with capital C). I will talk more about coinbase in other articles.

Each transaction output will generate one or more new bitcoin ‘UTXO’. The transaction output ‘lock’ the newly generated UTXO to the new owner’s public key/public key hash/script hash. This means that the new owner now owns the bitcoins from the newly generated UTXO. The new owner who receives the newly generated UTXO will keep the new UTXO in his/her wallet. These UTXOs are ‘unspent’ (unused) and are available to be ‘spent’ for subsequent transaction.

If the owner decides to use the UTXO for a new transaction, the owner must ‘unlock’ the UTXO using his/her signature/public key/script and ‘spent’ the UTXO as an input to the new transaction. When UTXO is spent, it’s no longer called UTXO. It’s now called STXO (Spent Transaction Output). Therefore, a transaction consumes existing UTXOs at the input, and also generates new UTXOs at the output.

UTXOs are kept in a database called UTXO set. Full node stores this database in its computer’s RAM (Random Access Memory). Full node uses UTXO to validate all newly generated transactions by checking if the owner has enough balance in his/her wallet for the transaction, or if the owner uses UTXO that he/she has spent or uses UTXO that he/she does not owe.

To elaborate a bit more on ‘unspent’ & ‘spent’, just imagine that you’ve got some bitcoins in your wallet. If your wallet shows 8 bitcoins balance, this means that your 8 bitcoins are in one or more UTXOs (for example 1 BTC UTXO, 2BTC UTXO, 5 BTC UTXO) waiting to be used. In other words, you have three ‘unspent’ options to use bitcoins. If you have chosen to use the 1 BTC option, this means that the 1 BTC option is ‘spent’. It will no longer be an option for you to use after you have ‘spent’ that option. Now you’ve just left with two options to use bitcoins, which is the option of 2 BTC and the option of 5BTC.

If you browse through some of the bitcoin transactions on the blockchain explorer, you may notice a red or green globe icon next to the output bitcoin value. The red globe icon means that output bitcoin is ‘spent,’ and the green globe icons means that output bitcoin is ‘unspent’.

Now we’re ready to look at an example when you want to send bitcoins to other people. Just follow the diagram step by step, which is quite self-explanatory.

I hope that the discussion so far will help you to understand UTXO better. It’s okay if you’re still confused about UTXO. It’s one of Bitcoin’s most difficult concepts to understand. It will be easy for you after a few readings. This concept will come in handy later for you to appreciate the unlocking/locking script.

Remember

· Bitcoin transaction is made up of input and output.

· Every bitcoin transaction has ‘unspent’ and/or ‘spent’ output.

· Bitcoin transaction consumes existing UTXO (at the input) by unlocking it with current owner’s signature/public key/script and generates new UTXO (at the output) by locking it to the new owner’s public key/public key hash/script hash.

--

--