<p>The blocks you mine contain a coinbase transaction, which pays the block reward to an address of your choice.  When mining in a pool, you set the payment address to the pool's address.  If you were to mine a block and try to change the payment address to your own address, this would change block hash and invalidate the block.  You can't cheat a pool by mining with your own payment address because they will check that.  Pools get a regular proof of work from their miners by giving them an easier difficulty target, so that the miner regularly passes mined blocks back to the pool which get checked.</p>

<p>So basically you either mine for a pool, which pays the pool, or you mine solo.  You can't do both at once.</p>

CC BY-SA 3.0
2013-05-08T08:12:25.257Z
2013-05-08T08:12:25.257Z
Ashley Holman
<p>When you are running a miner in a pool, you communicate through <code>getwork</code> protocol. It basically boils down to requesting work and sending back shares (and in rare cases, solutions to blocks). Work in getwork is a Block Header, <strong>not</strong> an entire Block. The coinbase transaction is encoded in the merkle root, but is not known to the miner. The block hash that creates a share or a block solution is ONLY valid for a given merkle root. If you change the coinbase, giving yourself all the money, you invalidate your solution and have to start over. If you are mining your own blocks, no pool should accept your shares (unless it is dumb).</p>

<p>To sum up - a miner does not know the coinbase transaction, nor can it change the block without invalidating it.</p>

<p>On the other hand, a miner can withhold a block solution while still submitting other shares. This will make the pool get less money while still having to potentially pay for those shares. This exploit can be detected by statistics though, so over a long period of time such a malicious miner can be found out.</p>

CC BY-SA 3.0
2013-05-08T09:24:34.127Z
How about the Stratum protocol? Does that work the same way?
Steven Roose
CC BY-SA 3.0
2013-05-08T20:01:05.400Z
@StevenRoose I am not sure. Looking at the protocol it is a bit confusing. I assume it should be resistant to such an attack if it pools rewards. I know P2Pool requires the coinbase transaction to adhere to some standards when it is created in regards to how the outputs should look. If either one of those two would not be resistant to such cheats, they would be exploited until they would either be dead or fixed. Something very similar happened with pool hopping exploit back in the day.
ThePiachu
CC BY-SA 3.0
2013-05-23T13:53:24.297Z
@StevenRoose: In Stratum, the miner can build the generation transaction himself. However, the transaction must credit the pool in its output - otherwise, the shares the miner submits will not be accepted by the pool.
Meni Rosenfeld
CC BY-SA 3.0
2013-05-08T09:06:52.883Z
2013-05-08T09:06:52.883Z
ThePiachu
<p>As I understand it,when mining BTC, and calculating a block, the goal is to find a SHA-256 hash below a certain value (with the previous block, a nonce, and other things as the input).  Are pool miners all performing that calculation directly (just with different nonces?)</p>

<p>If so, what prevents the miner who "finds" the block from keeping it, and not reporting it back to the pool?  I'm assuming there's some safeguard here, and the miners aren't actually going to find the full solution.</p>

CC BY-SA 3.0
2013-05-08T15:31:31.180Z
See the last paragraph of the answer that I have referred to as a duplicate. In short, he can't allocate the BTC to himself because the block he was asked to mine already allocated the mined BTC to the pool.He could, however, ignore the result if he is trying to subvert the pool. That's referred to a withholding attack.
David Ogren
CC BY-SA 3.0
2013-05-08T15:34:10.910Z
possible duplicate of [How is block-solution-withholding a threat to mining pools?](http://bitcoin.stackexchange.com/questions/1338/how-is-block-solution-withholding-a-threat-to-mining-pools)
David Ogren
<mining-pools>
What prevents a pool miner from stealing an entire block?
Jonathon Reinhart
# What prevents a pool miner from stealing an entire block?

(Asked by: username_0 on 2013-05-08)

As I understand it,when mining BTC, and calculating a block, the goal is to find a SHA-256 hash below a certain value (with the previous block, a nonce, and other things as the input). Are pool miners all performing that calculation directly (just with different nonces?)

If so, what prevents the miner who "finds" the block from keeping it, and not reporting it back to the pool? I'm assuming there's some safeguard here, and the miners aren't actually going to find the full solution.

**Tags:** mining-pools

> **Comments:**
> **username_1**: See the last paragraph of the answer that I have referred to as a duplicate. In short, he can't allocate the BTC to himself because the block he was asked to mine already allocated the mined BTC to the pool.He could, however, ignore the result if he is trying to subvert the pool. That's referred to a withholding attack.  
> **username_1**: possible duplicate of [How is block-solution-withholding a threat to mining pools?](http://bitcoin.stackexchange.com/questions/1338/how-is-block-solution-withholding-a-threat-to-mining-pools)  

---

## 2 answers

### Answer by username_3 on 2013-05-08. Score: 34 | Accepted answer

When you are running a miner in a pool, you communicate through `getwork` protocol. It basically boils down to requesting work and sending back shares (and in rare cases, solutions to blocks). Work in getwork is a Block Header, **not** an entire Block. The coinbase transaction is encoded in the merkle root, but is not known to the miner. The block hash that creates a share or a block solution is ONLY valid for a given merkle root. If you change the coinbase, giving yourself all the money, you invalidate your solution and have to start over. If you are mining your own blocks, no pool should accept your shares (unless it is dumb).

To sum up - a miner does not know the coinbase transaction, nor can it change the block without invalidating it.

On the other hand, a miner can withhold a block solution while still submitting other shares. This will make the pool get less money while still having to potentially pay for those shares. This exploit can be detected by statistics though, so over a long period of time such a malicious miner can be found out.

> **Comments:**
> **username_4**: How about the Stratum protocol? Does that work the same way?  
> **username_3**: @username_4 I am not sure. Looking at the protocol it is a bit confusing. I assume it should be resistant to such an attack if it pools rewards. I know P2Pool requires the coinbase transaction to adhere to some standards when it is created in regards to how the outputs should look. If either one of those two would not be resistant to such cheats, they would be exploited until they would either be dead or fixed. Something very similar happened with pool hopping exploit back in the day.  
> **username_5**: @username_4: In Stratum, the miner can build the generation transaction himself. However, the transaction must credit the pool in its output - otherwise, the shares the miner submits will not be accepted by the pool.  

---

### Answer by username_2 on 2013-05-08. Score: 18

The blocks you mine contain a coinbase transaction, which pays the block reward to an address of your choice. When mining in a pool, you set the payment address to the pool's address. If you were to mine a block and try to change the payment address to your own address, this would change block hash and invalidate the block. You can't cheat a pool by mining with your own payment address because they will check that. Pools get a regular proof of work from their miners by giving them an easier difficulty target, so that the miner regularly passes mined blocks back to the pool which get checked.

So basically you either mine for a pool, which pays the pool, or you mine solo. You can't do both at once.


---

