ckolivas/cgminer — pull request #638 by 4tar (2014-08-18 16:29:56+00:00)
Title: Initial version of coinbase check for cgminer

When do pool mining, users get job from the pool by being pushed stratum mining_notify message or firing GBT message, however if the pool was compromised by some malicious hackers then the job might generate no benefit for users. By introducing the coinbase checking function in the client, user can ensure that (how much of) the benefits, if any, is going to the expected address, so that greatly reduces the risk of wasting their hashing power. From another side, a pool that always generates coinbases passing users' check can give its client enough confidence to trust it.

The usage is pretty straightforward, three arguments are added, say --cbaddr, --cbtotal, and -cbperc, all are per-pool settings. --cbaddr specifies the address user want to check against in the coinbase txn, --cbtotal indicates the total amount of benefit the coinbase should include, while --cbperc tells the percentage in all benefit the --cbaddr specified address should obtain.

If any problem found in the coinbase data, this patch would suspend the pool for 10 minutes from generating workload. Note if none of these arguments was input by user, this patch would still work but just check the coinbase is integral regarding the standard format.

Here is the typical usage: cgminer -u XX -p YY -o stratum+tcp://thepool.com --cbaddr POOL_ADDR --cbtotal '>2499999999' --cbperc '>0.99'; the command would check whether the total amount output coins in the coinbase txn is more than 2499999999, and the POOL_ADDR would receive more that 99% of that.

Both "--cbtotal" and "--cbperc" arguments need a '>'/'+', '<'/'-', or '=' prefix to tell what kind of comparing the user want to check against the coinbase. Note when using '>' or '<', quotation marks ’ or " would be needed to avoid confusing the shell with I/O redirection, for convenience '+' or '-' can be used to replace '>' or '-', e.g. the above sample can be rewrite like: cgminer -u XX -p YY -o stratum+tcp://thepool.com --cbaddr POOL_ADDR --cbtotal +2499999999 --cbperc +0.99.

Besides that "--cbperc" obviously depends on "--cbaddr", the three new args can combines as users' will without any other restriction.

Patches including similar functions have also be submitted to other mining client.

Signed-off-by: Huang Le <4tarhl@gmail.com>