1
So I have been reading up on bitcoin and blockchain for awhile now, but I have yet to fully understand it. I understand that bitcoin leverage on DLT, which uses cryptography to verify transaction. This is what I have understood so far:
- When I make a transaction, this transaction is added to a pool of unconfirmed transactions
- This pool of unconfirmed transactions forms a block and miners will solve a mathematical problem as verification
- The first miner to solve it will have the block verified and added on to the chain
However, how do they know if my transaction is valid? What if I have 1 BTC but decide to send 2 BTC, how does the solving of mathematical problem verify that I do not have 2 BTC? What if I just purchased 5 BTC from Coinbase using fiat, how will anyone know that I have 5 BTC?
I believe this should not be a very difficult question but I cant seem to understand it fully. Hope someone can point be to the right direction and enlighten me thanks!
1When you say the transaction "consumes the UTXO", does this mean that all UTXOs (even if same value) are unique - no 2 UTXOs are the same in the UTXO set? – Jason Tay – 2019-10-20T17:15:48.203
Yes, exactly! Each UTXO is uniquely identifiable by their outpoint, a value derived from the transaction that created the UTXO and the position of the UTXO in that transaction's output list. I've amended my answer to include this point. – Murch – 2019-10-20T17:19:15.927
Got it, a final clarification: I am assuming this UTXO Set includes all transactions on the chain, as well as the pool of unconfirmed transactions - so what is the purpose of mining (hashing of block header to find a result smaller than the block target)? Since UTXOs are unique and already prevents double spending and verifies transactions? How does mining fit in here? – Jason Tay – 2019-10-20T17:40:34.053
Since Bitcoin is a distributed network, it is non-trivial to make everyone receive the same transactions at the same time. A malicious users can leverage the latency to create two transactions that spend the same inputs, e.g. submitting one directly to a merchant and another to the rest of the network. The merchant would think they got paid, the rest of the network would disagree. A block however, can only include one of the two transactions, so it allows the network to converge on one ground-truth. – Murch – 2019-10-20T18:32:27.517
Would'nt the creation of two transactions that spend the same inputs be disallowed in the first place - since UTXOs are unique and will be rejected by the validation nodes? – Jason Tay – 2019-10-20T23:59:39.753
Yes, that's right, but it's possible for some nodes to see the original version of the transaction first, while other nodes see the competing transaction first. – Murch – 2019-10-21T00:18:30.273