46

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.

2
  • 2
    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. May 8, 2013 at 15:31
  • possible duplicate of How is block-solution-withholding a threat to mining pools? May 8, 2013 at 15:34

2 Answers 2

32

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.

3
  • 2
    How about the Stratum protocol? Does that work the same way? May 8, 2013 at 9:24
  • @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
    May 8, 2013 at 20:01
  • 1
    @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. May 23, 2013 at 13:53
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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.