<p>The purpose of mining is not verification but putting transactions into a sequence, a specific order.</p>
<p>Miners publish blocks of transactions in order.</p>
<p>If two or more miners publish a block at the same time, other nodes will eventually choose the block that forms the chain with the most work. The hash must be less than the current target independently calculated by every node.</p>
<p>When a transaction is included in a block, we say it is confirmed. Confirmation is not verification. Confirmation is of the order of transactions.</p>
<p>Verification is a checking of correctness performed by every Bitcoin node, including wallets. It is not a service performed for others. One of the checks is that a transaction does not spend money already spent by a transaction earlier in the order.</p>

CC BY-SA 4.0
2023-10-13T10:05:55.143Z
This whole bitcoin thing confuses me. What's the point of a blockchain and why does it need to be maintained? How does one 'double spend' and how can they be prevented from doing so? I swear I've read so much on it and it just seems like words to me. You don't have to answer all the questions, I'm just being expressively confused and frustrated
Johnafoon
CC BY-SA 4.0
2023-10-13T10:09:26.760Z
@Johnafoon: Try the search facility here, there are probably good answers to those questions.
RedGrittyBrick
CC BY-SA 4.0
2023-10-13T17:52:05.057Z
Nodes extend their best chain with the first block they hear about. They will only reorganize if they learn about a chaintip with _more work_. As long as two chaintips are tied in work, nodes will stick to whatever chaintip they first heard about. If a lower hash were a tie breaker between competing chaintips that would enable selfish-mining and a variant of the Finney attack: https://bitcoin.stackexchange.com/q/53825/5406
Murch
CC BY-SA 4.0
2023-10-13T09:26:23.080Z
2023-10-13T18:07:04.573Z
2023-10-13T18:07:04.573Z
RedGrittyBrick
<p>You can think of transactions as <a href="https://bitcoin.stackexchange.com/questions/63556/is-a-wallet-simply-a-folder-of-private-keys/115830#115830">destroying bills and creating new bills of total same value</a>. Nodes maintain a current database of active bills, and will reject a transaction trying to use an old bill. That's the double-spend check. It requires look-up / delete / insert operations with the UTXO database.</p>
<p>Popular belief is that miners get paid for the job of verifying and assembling transactions into blocks, but that is wrong. That is a job any node is capable of doing and it doesn't cost them much. Your RPi node can assemble transactions into a &quot;block template&quot;, but it just can't fill in the 1 blank that will satisfy the last consensus rule it needs to satisfy to be a valid block - the PoW difficulty check. That's why you can't simply kick out one block and replace it with another, because finding that nonce takes time. PoW's purpose is to increase the cost of undo.</p>
<p>Miners get paid for the job of filling in the nonce that will produce a satisfying block header hash, they get paid for the hashes because the only way to find a satisfying nonce is to make lots of guesses and hash the guesses. The network essentially bids for the hashes with block reward subsidy and users bid for the hashes with their transaction fees, and the more total reward the more secure the whole network becomes* since the cost of &quot;undoing&quot; a block will be bigger because difficulty will grow higher.
(*assuming constant price)</p>
<p>Each transaction is a business transaction with a miner, they're the recipient of the implicit output (the fee), which is a payment from user for the service of maintaining the immutability property of the ledger! Of course miners would include their own business transactions into blocks they create!</p>
<p>During the early days of Bitcoin, nodes did all these jobs:</p>
<ol>
<li>Verified incoming transactions and blocks</li>
<li>Made their own transactions and broadcast them to the network</li>
<li>Assembled transactions into a block template (full block, with just the nonce missing)</li>
<li>Filled in the nonce to make the block header pass the PoW check</li>
</ol>
<p>Since then, the jobs have been separated.</p>
<p>Now it's mostly pools who do 1-3, and &quot;miners&quot; are just blindly doing the 4.: getting 80 bytes of block header from the pool and grinding the nonce. How do the miners verify what they're mining? Well, they have to get paid eventually, right?</p>
<p>Miners get paid their reward from the pool, so to independently verify they're getting paid correctly in proportion to their work, they also need to have some regular node, which can be off-site and doesn't need to be involved in mining! In that case they run a node to verify they themselves got paid for some past work in the right currency! This gives pools the power to direct hash-power of many as they like, but the pool can't really hide what they're doing, so everyone's on good behavior.</p>
<p>Note that &quot;miners&quot; are not exclusive to a single blockchain network. All Bitcoin miners are sha256d miners, but not all sha256d miners are Bitcoin miners! The era of one blockchain is long gone. Networks bid for the hashes, miners sell the hashes.</p>
<p>What happens if a subset of nodes changes the rules? All nodes under old rules will reject changed rules, and all nodes with changed rules will reject old rules. This happened in 2017 with the BCH fork. If both will be mined, then both will continue to exist independently.
Which will get more hashes? It will depend on market price.</p>
<p>Miners pay for their energy usage and hardware in some external currency, they have to exchange it to pay the bills. If they can exchange the blockchain's native currency (BTC, BCH) for the cost currency (USD, CNY), and still have something left -- then they can make a profit. Their profit depends on there being liquidity for the native currency and the native currency having value! So they don't just arbitrarily decide which network to mine. They have strong incentive to get a ROI on their hardware, and optimal mining is to mine ALL networks which have a liquid market for the rewards, and in proportion to market value of their block rewards.</p>

CC BY-SA 4.0
2023-10-13T10:34:40.243Z
2023-10-14T07:39:46.027Z
2023-10-14T07:39:46.027Z
bca-0353f40e
<p>I’m very much new to understanding this whole bitcoin concept. As far as I’m concerned, nodes mine for a nonce that, when paired with the data of the block, result in a hash that suffices some requirement (like it needs to start with six 0s). I’m also under the impression that this process is what verifies the user isn’t ‘double-spending’ and has sufficient funds. How does doing this help confirm that?</p>
<p>Edit: and also a block is just a bunch of unverified transactions along with some additional data, right?</p>

<bitcoin-core><protocol><transaction-verification>
How does mining verify a transaction?
Johnafoon
# How does mining verify a transaction?

(Asked by: username_0 on 2023-10-13)

I’m very much new to understanding this whole bitcoin concept. As far as I’m concerned, nodes mine for a nonce that, when paired with the data of the block, result in a hash that suffices some requirement (like it needs to start with six 0s). I’m also under the impression that this process is what verifies the user isn’t ‘double-spending’ and has sufficient funds. How does doing this help confirm that?

Edit: and also a block is just a bunch of unverified transactions along with some additional data, right?

**Tags:** bitcoin-core, protocol, transaction-verification


---

## 2 answers

### Answer by username_1 on 2023-10-13. Score: 2

The purpose of mining is not verification but putting transactions into a sequence, a specific order.

Miners publish blocks of transactions in order.

If two or more miners publish a block at the same time, other nodes will eventually choose the block that forms the chain with the most work. The hash must be less than the current target independently calculated by every node.

When a transaction is included in a block, we say it is confirmed. Confirmation is not verification. Confirmation is of the order of transactions.

Verification is a checking of correctness performed by every Bitcoin node, including wallets. It is not a service performed for others. One of the checks is that a transaction does not spend money already spent by a transaction earlier in the order.

> **Comments:**
> **username_0**: This whole bitcoin thing confuses me. What's the point of a blockchain and why does it need to be maintained? How does one 'double spend' and how can they be prevented from doing so? I swear I've read so much on it and it just seems like words to me. You don't have to answer all the questions, I'm just being expressively confused and frustrated  
> **username_1**: @username_0: Try the search facility here, there are probably good answers to those questions.  
> **username_2**: Nodes extend their best chain with the first block they hear about. They will only reorganize if they learn about a chaintip with _more work_. As long as two chaintips are tied in work, nodes will stick to whatever chaintip they first heard about. If a lower hash were a tie breaker between competing chaintips that would enable selfish-mining and a variant of the Finney attack: https://bitcoin.stackexchange.com/q/53825/5406  

---

### Answer by username_3 on 2023-10-13. Score: 1

You can think of transactions as [destroying bills and creating new bills of total same value](https://bitcoin.stackexchange.com/questions/63556/is-a-wallet-simply-a-folder-of-private-keys/115830#115830). Nodes maintain a current database of active bills, and will reject a transaction trying to use an old bill. That's the double-spend check. It requires look-up / delete / insert operations with the UTXO database.

Popular belief is that miners get paid for the job of verifying and assembling transactions into blocks, but that is wrong. That is a job any node is capable of doing and it doesn't cost them much. Your RPi node can assemble transactions into a "block template", but it just can't fill in the 1 blank that will satisfy the last consensus rule it needs to satisfy to be a valid block - the PoW difficulty check. That's why you can't simply kick out one block and replace it with another, because finding that nonce takes time. PoW's purpose is to increase the cost of undo.

Miners get paid for the job of filling in the nonce that will produce a satisfying block header hash, they get paid for the hashes because the only way to find a satisfying nonce is to make lots of guesses and hash the guesses. The network essentially bids for the hashes with block reward subsidy and users bid for the hashes with their transaction fees, and the more total reward the more secure the whole network becomes\* since the cost of "undoing" a block will be bigger because difficulty will grow higher.
(\*assuming constant price)

Each transaction is a business transaction with a miner, they're the recipient of the implicit output (the fee), which is a payment from user for the service of maintaining the immutability property of the ledger! Of course miners would include their own business transactions into blocks they create!

During the early days of Bitcoin, nodes did all these jobs:

1. Verified incoming transactions and blocks
2. Made their own transactions and broadcast them to the network
3. Assembled transactions into a block template (full block, with just the nonce missing)
4. Filled in the nonce to make the block header pass the PoW check

Since then, the jobs have been separated.

Now it's mostly pools who do 1-3, and "miners" are just blindly doing the 4.: getting 80 bytes of block header from the pool and grinding the nonce. How do the miners verify what they're mining? Well, they have to get paid eventually, right?

Miners get paid their reward from the pool, so to independently verify they're getting paid correctly in proportion to their work, they also need to have some regular node, which can be off-site and doesn't need to be involved in mining! In that case they run a node to verify they themselves got paid for some past work in the right currency! This gives pools the power to direct hash-power of many as they like, but the pool can't really hide what they're doing, so everyone's on good behavior.

Note that "miners" are not exclusive to a single blockchain network. All Bitcoin miners are sha256d miners, but not all sha256d miners are Bitcoin miners! The era of one blockchain is long gone. Networks bid for the hashes, miners sell the hashes.

What happens if a subset of nodes changes the rules? All nodes under old rules will reject changed rules, and all nodes with changed rules will reject old rules. This happened in 2017 with the BCH fork. If both will be mined, then both will continue to exist independently.
Which will get more hashes? It will depend on market price.

Miners pay for their energy usage and hardware in some external currency, they have to exchange it to pay the bills. If they can exchange the blockchain's native currency (BTC, BCH) for the cost currency (USD, CNY), and still have something left -- then they can make a profit. Their profit depends on there being liquidity for the native currency and the native currency having value! So they don't just arbitrarily decide which network to mine. They have strong incentive to get a ROI on their hardware, and optimal mining is to mine ALL networks which have a liquid market for the rewards, and in proportion to market value of their block rewards.


---

