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!

2

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 UTXO in the inputs, and assigns value to newly created UTXO in the outputs.

Other network participants running a type of Bitcoin software called "fully validating nodes" have followed along the full history of all of Bitcoin's transactions (the "blockchain") to maintain a complete set of all UTXO 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.

UTXO 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 UTXO the transaction references 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 UTXO, 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.

  • 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 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 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 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 at 18:32
  • 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 Oct 20 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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