<blockquote>
  <p>When the output gets consumed by a later transaction, who and how prevents this output from being consumed a second time? Do we go over all the transactions after to make sure it hasn't been used?</p>
</blockquote>

<p>Full nodes keep track of all unspent outputs in the blockchain, known as UTXOs (unspent transaction outputs). This is the UTXO set. When a transaction in the blockchain spends a UTXO, it is removed from that set, and new UTXOs are added for the new outputs from that transaction. This happens every time a new block is received. If a transaction tries to spend a UTXO which isn't in the set, the node sees it as invalid. To that node, there is no difference between spending from a transaction which has already been spent, or one which never existed. Either way, there is no valid UTXO to spend from in the UTXO set, so its an invalid transaction.</p>

CC BY-SA 3.0
2018-01-15T11:56:17.727Z
2018-01-15T11:56:17.727Z
meshcollider
<p>I am trying to understand the mechanics of how a bitcoin transaction works. When the output gets consumed by a later transaction, who and how prevents this output from being consumed a second time? Do we go over all the transactions after to make sure it hasn't been used?</p>

<p>I am not sure what are the right tags for this kind of questions</p>

CC BY-SA 3.0
2018-01-15T10:43:56.523Z
Possible duplicate of [Double Spending - Does each node maintain a list of unspent transaction references?](https://bitcoin.stackexchange.com/questions/32698/double-spending-does-each-node-maintain-a-list-of-unspent-transaction-referenc)
sourav
<doublespend><utxo><utxo-set>
What are the mechanics of verifying that an output transaction is not spent?
blenddd
# What are the mechanics of verifying that an output transaction is not spent?

(Asked by: username_0 on 2018-01-15)

I am trying to understand the mechanics of how a bitcoin transaction works. When the output gets consumed by a later transaction, who and how prevents this output from being consumed a second time? Do we go over all the transactions after to make sure it hasn't been used?

I am not sure what are the right tags for this kind of questions

**Tags:** doublespend, utxo, utxo-set

> **Comments:**
> **username_1**: Possible duplicate of [Double Spending - Does each node maintain a list of unspent transaction references?](https://bitcoin.stackexchange.com/questions/32698/double-spending-does-each-node-maintain-a-list-of-unspent-transaction-referenc)  

---

## 1 answers

### Answer by username_2 on 2018-01-15. Score: 0 | Accepted answer

> When the output gets consumed by a later transaction, who and how prevents this output from being consumed a second time? Do we go over all the transactions after to make sure it hasn't been used?

Full nodes keep track of all unspent outputs in the blockchain, known as UTXOs (unspent transaction outputs). This is the UTXO set. When a transaction in the blockchain spends a UTXO, it is removed from that set, and new UTXOs are added for the new outputs from that transaction. This happens every time a new block is received. If a transaction tries to spend a UTXO which isn't in the set, the node sees it as invalid. To that node, there is no difference between spending from a transaction which has already been spent, or one which never existed. Either way, there is no valid UTXO to spend from in the UTXO set, so its an invalid transaction.


---

