3

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!

1 Answer 1

4

When you spend Bitcoin in a transaction, the transaction must reference at least one existing unspent transaction output (UTXO) and provide a valid signature proving that you are authorized to spend it. The transaction then consumes the UTXOs in the inputs, and assigns value to newly created UTXOs in the outputs.

Other network participants running a type of Bitcoin software called "fully validating nodes" have followed along the full history of all Bitcoin transactions (the "blockchain") to maintain a complete set of all UTXOs in existence (the "UTXO set"). You can think of the blockchain as the journal of all transactions, and the UTXO set as the ledger of all Bitcoin balances.

UTXOs are uniquely identifiable by their "outpoint" which is composed of the transaction id that created the output and their position in the transaction's output list: txid:vout. This means that each full node can look up whether the UTXOs the transaction spends in the inputs exist in their UTXO set. They also check that the transaction is correctly constructed, including whether the transaction fulfills the locking conditions of the UTXOs, whether the signatures are valid, and that the transaction does not create new money by assigning more to the outputs than the inputs brought in.

6
  • 1
    When 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
    Oct 20, 2019 at 17:15
  • 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
    Oct 20, 2019 at 17:19
  • 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
    Oct 20, 2019 at 17:40
  • 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
    Oct 20, 2019 at 18:32
  • 1
    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
    Oct 21, 2019 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.