<p>Funds in Bitcoin are tracked in the form of <em>Unspent Transaction Outputs (UTXOs)</em>. Every fully validating node processes the entire blockchain to calculate the currently existing spendable funds, the <em>Unspent Transaction Output set (UTXO set)</em>.</p>
<p>When a node learns about a new transaction, it removes the UTXOs spent by the transaction from the UTXO set: UTXOs only can be spent in full, using one as an input uses it up completely.</p>
<p>If later the node learns about a second transaction that spends one of the same UTXOs, the UTXO will no longer be in the UTXO set, and the transaction will be rejected due to spending funds that are not available for spending.</p>

CC BY-SA 4.0
2023-02-07T05:32:44.630Z
Do I understand correctly, based on what you said, that in already mined blocks, transactions are changed, their utxo is removed and transferred to the new transaction? I imagined the block as an immutable structure.
6blBaJlblu reoJlor
CC BY-SA 4.0
2023-02-07T11:14:38.607Z
@6blBaJlblureoJlor: A transaction destroys UTXOs which are in its inputs. A transaction creates new UTXOs in its outputs. There is no correspondence between old and new UTXOs. It is as if they were gold coins melted down together into a pool of thoroughly mixed amorphous  molten gold from which some new gold coins are made. Blocks are immutable. UTXOs are ephemeral. A UTXO is simply an immutable TXO that has not yet been referenced in an input of a later transaction.
RedGrittyBrick
CC BY-SA 4.0
2023-02-07T12:30:10.057Z
You just have to declare which UTXOs your transaction is spending and every node then updates their ledger to mark them as spent. The UTXOs themselves do not need to be modified.
Murch
CC BY-SA 4.0
2023-02-06T20:58:41.787Z
2023-02-11T12:09:36.343Z
2023-02-11T12:09:36.343Z
Murch
<p>How does transaction validation verify that I am not trying to send transactions with the same txin? Does transaction validation go through all the blocks and make sure I'm not trying to write off funds from transactions that are already out of money?</p>

CC BY-SA 4.0
2023-02-06T18:46:05.957Z
Possible duplicate of: https://bitcoin.stackexchange.com/q/56587/5406
Murch
CC BY-SA 4.0
2023-02-06T20:14:01.613Z
The answer is essentially yes. I expect most wallets make use of an optimisation in that they keep a list of unspent transaction outputs which is shorter than the list of all transactions and therefore can be searched faster and can also be indexed more easily.
RedGrittyBrick
CC BY-SA 4.0
2023-02-18T21:01:40.913Z
Does this answer your question? [How does Bitcoin protect against doublespends?](https://bitcoin.stackexchange.com/questions/56587/how-does-bitcoin-protect-against-doublespends)
Mercedes
<transactions><doublespend><utxo><mempool>
Transaction with txin, which ran out of money
6blBaJlblu reoJlor
# Transaction with txin, which ran out of money

(Asked by: username_0 on 2023-02-06)

How does transaction validation verify that I am not trying to send transactions with the same txin? Does transaction validation go through all the blocks and make sure I'm not trying to write off funds from transactions that are already out of money?

**Tags:** transactions, doublespend, utxo, mempool

> **Comments:**
> **username_1**: Possible duplicate of: https://bitcoin.stackexchange.com/q/56587/5406  
> **username_2**: The answer is essentially yes. I expect most wallets make use of an optimisation in that they keep a list of unspent transaction outputs which is shorter than the list of all transactions and therefore can be searched faster and can also be indexed more easily.  
> **username_3**: Does this answer your question? [How does Bitcoin protect against doublespends?](https://bitcoin.stackexchange.com/questions/56587/how-does-bitcoin-protect-against-doublespends)  

---

## 1 answers

### Answer by username_1 on 2023-02-06. Score: 2 | Accepted answer

Funds in Bitcoin are tracked in the form of *Unspent Transaction Outputs (UTXOs)*. Every fully validating node processes the entire blockchain to calculate the currently existing spendable funds, the *Unspent Transaction Output set (UTXO set)*.

When a node learns about a new transaction, it removes the UTXOs spent by the transaction from the UTXO set: UTXOs only can be spent in full, using one as an input uses it up completely.

If later the node learns about a second transaction that spends one of the same UTXOs, the UTXO will no longer be in the UTXO set, and the transaction will be rejected due to spending funds that are not available for spending.

> **Comments:**
> **username_0**: Do I understand correctly, based on what you said, that in already mined blocks, transactions are changed, their utxo is removed and transferred to the new transaction? I imagined the block as an immutable structure.  
> **username_2**: @username_0: A transaction destroys UTXOs which are in its inputs. A transaction creates new UTXOs in its outputs. There is no correspondence between old and new UTXOs. It is as if they were gold coins melted down together into a pool of thoroughly mixed amorphous  molten gold from which some new gold coins are made. Blocks are immutable. UTXOs are ephemeral. A UTXO is simply an immutable TXO that has not yet been referenced in an input of a later transaction.  
> **username_1**: You just have to declare which UTXOs your transaction is spending and every node then updates their ledger to mark them as spent. The UTXOs themselves do not need to be modified.  

---

