<p>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.</p>
<p>Other network participants running a type of Bitcoin software called &quot;fully validating nodes&quot; have followed along the full history of all Bitcoin transactions (the &quot;blockchain&quot;) to maintain a complete set of all UTXOs in existence (the &quot;UTXO set&quot;). You can think of the blockchain as the journal of all transactions, and the UTXO set as the ledger of all Bitcoin balances.</p>
<p>UTXOs are uniquely identifiable by their &quot;outpoint&quot; which is composed of the transaction id that created the output and their position in the transaction's output list: <code>txid:vout</code>.
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.</p>

CC BY-SA 4.0
2019-10-20T17:15:48.203Z
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
CC BY-SA 4.0
2019-10-20T17:19:15.927Z
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
CC BY-SA 4.0
2019-10-20T17:40:34.053Z
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
CC BY-SA 4.0
2019-10-20T18:32:27.517Z
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
CC BY-SA 4.0
2019-10-20T23:59:39.753Z
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
CC BY-SA 4.0
2019-10-21T00:18:30.273Z
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
CC BY-SA 4.0
2019-10-20T16:42:06.430Z
2021-01-25T20:43:17.853Z
2021-01-25T20:43:17.853Z
Murch
<p>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:</p>

<ul>
<li>When I make a transaction, this transaction is added to a pool of unconfirmed transactions</li>
<li>This pool of unconfirmed transactions forms a block and miners will solve a mathematical problem as verification</li>
<li>The first miner to solve it will have the block verified and added on to the chain</li>
</ul>

<p>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?</p>

<p>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!</p>

<transaction-verification><validation>
How to tell if a transaction is valid?
Jason Tay
# How to tell if a transaction is valid?

(Asked by: username_0 on 2019-10-20)

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!

**Tags:** transaction-verification, validation


---

## 1 answers

### Answer by username_1 on 2019-10-20. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  
> **username_1**: 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.  
> **username_0**: 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?  
> **username_1**: 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.  
> **username_0**: 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?  
> **username_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.  

---

