The first time i checked one of my Bitcoin transactions on a block explorer, i was really confused, this because I have only send BTC to one person, but the transaction is showing two outputs. For some moment i thought that Have mistakenly send Bitcoin twice. But after learning how BTC uses UTXO model, i understand what was happening.
For some of us that won’t understand what Inputs and Outputs meansInputs:in a simple language is the coins that you are spending. So therefore your wallet does not store Bitcoin or UTXOs. UTXOs exist on the Bitcoin blockchain, while our wallet plays a role of keeping the keys that will allow you to spend them.
Inputs are previously received UTXOs that your wallet selects when creating a new transaction. So wallet gather one or more UTXOs as inputs whenever you send Bitcoin.
Given an example below
Your received Inputs:0.2 BTC
0.2 BTC
0.1 BTC
Total available input =0.5 BTC
And now you want to send :0.4 BTC
Wallet selects all 3 UTXOs as inputs.
Outputs :0.4 BTC (receiver)
0.0999 BTC (your change)
Difference:
0.0001 BTC (Miner Fee)
Outputs: in a simple language means where your coins go after your transaction. A Transaction can have one or multiple payment outputs. And in a situation we’re their is an Bitcoin left after paying the recipient and the miner fee, this also create a change output that sends the remaining BTC to your wallet .
What I really love about it does not work like our bank account. Bitcoin does not subtract coins from a running balance rather it spends the available UTXOs and do create a new one.
Common Confusion Most of us might be wondering why will I send 0.4 BTC but 0.5 BTC end up leaving my wallet ?
This happens because your wallet spent 0.5 BTC input, from this very input 0.4 BTC will go to the receiver. Then 0.1 minus fee will come back to you as a change.
Let me give this example like this, think of paying with a $10 bill. In other to buy stuff worth $4 and you give out the whole $10. We won’t have the cashier to tear the bill into two pieces. Rather, they keep the $10 bill and have to give back $6 in return as change. This makes Bitcoin works in a similar way by spending whole UTXOs and creating new outputs.
Why is Bitcoin design this way ?Bitcoin doesn’t use account balance model rather it uses UTXO model. This way makes every transactions easier to be verified, and this prevent coins spent partially.
Question for us all Before you understood how UTXOs works did seeing 2 Outputs in a Bitcoin transaction make you think that you had sent Bitcoin twice ?
https://www.mtpelerin.com/blog/how-do-bitcoin-transactions-work