<p>Fully validating nodes have parsed the complete blockchain in order to autonomously determine the set of Unspent Transaction Outputs (UTXOs). When such a full node learns about a new block it checks that the block header is well-formed and then validates every single transaction. One part of the transaction validation is to confirm that all of the UTXOs the transactions are spending are available for spending (and only spent once). Blocks also have to fulfill <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages" rel="nofollow noreferrer">a few other rules</a>:</p>
<p><a href="https://i.sstatic.net/8OQB5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8OQB5.png" alt="Rules for block validation" /></a>
<sup>(Note: I haven't verified whether this article on the Bitcoin Wiki is up-to-date)</sup></p>
<p>If a block is noncompliant to any single rule, any full node will recognize this and reject the block. This famously <a href="https://crypto.news/antpool-mines-block-loses-12-5-btc-reward/" rel="nofollow noreferrer">happened</a> to AntPool on July 10, 2019, when they published a block that collected a greater block reward than allowed (highlighted in rules screenshot). AntPool did the work, but the block was invalid and immediately rejected by the network.</p>

CC BY-SA 4.0
2022-05-02T16:16:23.180Z
2022-05-03T14:35:06.830Z
2022-05-03T14:35:06.830Z
Murch
<p>All nodes, not just miners, check that the inputs to transactions in a block have not already been spent. All full nodes (wallets such as Bitcoin core) keep track of unspent transaction outputs (UTXOs).</p>
<p>No nodes trust other nodes, no nodes trust miners. All nodes check (validate) everything that can be validated.</p>

CC BY-SA 4.0
2022-05-02T16:10:45.083Z
2022-05-02T16:10:45.083Z
RedGrittyBrick
<p>For a node to accept an <em>invalid transaction</em>, that is, one with an invalid UTXO, inexistent balance or already spent balance, that node should need to slightly change the code and, <strong>by doing that</strong>, it will be, <em>de facto</em>, withdrawing itself from the 'consensus' and as such, the maximum aspiration of that said node would be to become a fork if some other nodes would install or follow that modified code.</p>
<p>It is just impossible to achieve what you describe and that is why every 10 minutes on average we are confirming blocks following the strict consensus that those UTXOs or balances associated with an specific TXID and Index were not spent before.</p>

CC BY-SA 4.0
2022-05-03T10:55:24.523Z
2022-05-03T10:55:24.523Z
abellido
<p>If proof of work is a consensus algorithm that guards against malicious nodes from adding faulty blocks, what actually happens when a miner successfully confirms a fraudulent block (i.e. a block that contains double spending transactions or other fraudulent transactions) by nonce guessing? In order for a miner to extend the “correct” block, there has to be some way to validate individual transactions in a broadcasted solution. If validation is simply checking whether the same inputs (transactions, nonce, etc) leads to the same hash, then there is no method for distinguishing blocks that contain faulty transactions and blocks that contain only true transactions. What is this algorithm that miners use to validate individual transactions in a broadcasted solution before deciding to abandon the block they are currently working on?</p>

<full-node><transaction-verification><block-validity>
What algorithm do miners use to validate individual transactions in a broadcasted solution before accepting it to their blockchain?
Wonjae Oh
# What algorithm do miners use to validate individual transactions in a broadcasted solution before accepting it to their blockchain?

(Asked by: username_0 on 2022-05-02)

If proof of work is a consensus algorithm that guards against malicious nodes from adding faulty blocks, what actually happens when a miner successfully confirms a fraudulent block (i.e. a block that contains double spending transactions or other fraudulent transactions) by nonce guessing? In order for a miner to extend the “correct” block, there has to be some way to validate individual transactions in a broadcasted solution. If validation is simply checking whether the same inputs (transactions, nonce, etc) leads to the same hash, then there is no method for distinguishing blocks that contain faulty transactions and blocks that contain only true transactions. What is this algorithm that miners use to validate individual transactions in a broadcasted solution before deciding to abandon the block they are currently working on?

**Tags:** full-node, transaction-verification, block-validity


---

## 3 answers

### Answer by username_1 on 2022-05-02. Score: 1 | Accepted answer

Fully validating nodes have parsed the complete blockchain in order to autonomously determine the set of Unspent Transaction Outputs (UTXOs). When such a full node learns about a new block it checks that the block header is well-formed and then validates every single transaction. One part of the transaction validation is to confirm that all of the UTXOs the transactions are spending are available for spending (and only spent once). Blocks also have to fulfill [a few other rules](https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages):

[![Rules for block validation](https://i.sstatic.net/8OQB5.png)](https://i.sstatic.net/8OQB5.png)
(Note: I haven't verified whether this article on the Bitcoin Wiki is up-to-date)

If a block is noncompliant to any single rule, any full node will recognize this and reject the block. This famously [happened](https://crypto.news/antpool-mines-block-loses-12-5-btc-reward/) to AntPool on July 10, 2019, when they published a block that collected a greater block reward than allowed (highlighted in rules screenshot). AntPool did the work, but the block was invalid and immediately rejected by the network.


---

### Answer by username_2 on 2022-05-02. Score: 1

All nodes, not just miners, check that the inputs to transactions in a block have not already been spent. All full nodes (wallets such as Bitcoin core) keep track of unspent transaction outputs (UTXOs).

No nodes trust other nodes, no nodes trust miners. All nodes check (validate) everything that can be validated.


---

### Answer by username_3 on 2022-05-03. Score: 0

For a node to accept an *invalid transaction*, that is, one with an invalid UTXO, inexistent balance or already spent balance, that node should need to slightly change the code and, **by doing that**, it will be, *de facto*, withdrawing itself from the 'consensus' and as such, the maximum aspiration of that said node would be to become a fork if some other nodes would install or follow that modified code.

It is just impossible to achieve what you describe and that is why every 10 minutes on average we are confirming blocks following the strict consensus that those UTXOs or balances associated with an specific TXID and Index were not spent before.


---

