user139975: 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?

user5406: 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.

139975: <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>
 5406: <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>
