What are UTXOs ?
In Bitcoin there are no sender, recipients ,coins, addresses; these things are use to abstract complexity for users. when your wallet says you received 1 BTC, it means it has detected a UTXO. A transactions is a collection of zero or more and outputs. These input and output objects are called Unspent Transaction Outputs (UTXO).
Bitcoin uses a model on Unspent Transaction Outputs (UTXO) and it is quite hard for a new users to grasp. Each transactions in bitcoin is called an Unspent Transaction Output (UTXO). Each incoming transaction remains distinct in your wallet as a UTXO, your wallet just abstracts that complexity and gives you the aggregate amount of your UTXOs.
How UTXO works
Take for instance I have one 200 naira note, one 100 naira note and two 50 naira note.
I want buy A bottle of coke ( 150 naira).
I have two options
Pay the 200 naira note to the seller and receive 50 naira as change( which will be used to pay for future transactions).
Or take the only 100 note and one 50 naira note.
Your wallet balance is the amount of your UTXOs and if the value of UTXO is larger than the value of transaction, it would not be divided because transaction outputs are not divisible, but consumed as a whole and change is generated. To simplify it, if you have a UTXO worth 2 bitcoin and you have for pay for pizza worth 1 bitcoin. your transaction must consume the whole 2-bitcoin UTXO and produce two outputs: one paying 1 bitcoin to your desired recipient and another paying 1 bitcoin in change back to your wallet. Note : This is just a simplification, so we did not factor transaction fees
Differences between UTXO model and cash based system
The differences between UTXO model and cash based is that is that ;
- In cash payment, you rely on recipient/counterparty to return change but in UTXO model, the recipient is never in control of change.
- Cash exists in defined, discrete denominations ( 50 naira, 100 naira ), while A transaction output can have an arbitrary (integer) value denominated as a multiple of satoshis .
PROs of UTXO mechanism in bitcoin
VALIDATION : The advantage that UTXOs have is that each UTXO can be traced back TO the point where the actual bitcoin was created (miner reward for example) and even back to the genesis block potentially.
It also gives security to the system because it is easy to verify transactions at every facet
Because wallets have abstracted the process of sending bitcoin, you just have to input the address you want to send money to and amount of bitcoin (provided it is lower than amount of bitcoin you have n your wallet). Under the hood the wallet does a lot of things and one of them is checking of is checking if your UTXOs are spendable and there is one way to do that with the bitcoin-cli ;
In order to create a new raw transaction, you must know what UTXOs you have on-hand to spend. You can determine this information with the bitcoin-cli listunspent
command (you must have installed Bitcoin core on your setup to try this or you can use this online regtest environment )
Because it is an online regtest environment, use the command
bitcoin-cli generate 101
to mine a block and get bitcoin as reward.Use the
bitcoin-cli listunspent
to see UTXOs you have.We only have one UTXO, which is the block reward from
bitcoin-cli generate 101
command.From the information in our command line, it tells us our UTXO is spendable and the amount is 50BTC.
$ bitcoin-cli listunspent
[
{
"txid": "ed30fb646948f6317550a6b51d2d5b38be971adea888aba6fa46d9bcee878834",
"vout": 0,
"address": "n2qWS3c6MRRE6HUgNH3qvrV4PhJEWh4mnU",
"scriptPubKey": "210296f396f1d14cfde84bdc10639e45533433dd1a93eda427a110aa0a80e322312dac",
"amount": 50.00000000,
"confirmations": 101,
"spendable": true,
"solvable": true,
"safe": true
}
]
UTXOs are very important concepts in bitcoin because everything we do is geared towards creating a transaction. I hope you enjoyed reading this, comment, ask questions and give a reaction.