I’m trying to determine how to properly convert difficulty from a mining.set_difficulty message to target for Litecoin, similar to how it’s done for Bitcoin.
For Bitcoin, the process I use is as follows:
- I start with the genesis
nbitsvalue:0x1d00ffff - I convert this to the max target:
0x00000000ffff0000000000000000000000000000000000000000000000000000 - Then, I calculate the target using this formula:
target = max_target / difficultyFor example, with a difficulty of
524288, the target becomes:target = max_target / 524288 = 0x0000000000001fffe00000000000000000000000000000000000000000000000
Now, I’m trying to apply a similar algorithm to Litecoin. Here’s what I have so far:
- The genesis
nbitsfor Litecoin is0x1e0ffff0 - I convert this to the same max target as in Bitcoin:
0x00000000ffff0000000000000000000000000000000000000000000000000000 - I use the formula
max_target / 524288, which results in the same target as in Bitcoin:target = 0x0000000000001fffe00000000000000000000000000000000000000000000000
However, when I perform this calculation and compare it with the shares I receive on the pool side, I find that some shares have a higher target, such as:
0x0000000005713013fcbf8bf0dcc329a5f56b856c2dbe64603e34b47169eaaa50
Upon further investigation, I found this code snippet, which introduces a coefficient of 65535:
if (opt_algo == ALGO_SCRYPT)
diff_to_target(work->target, sctx->job.diff / 65536.0);
else
diff_to_target(work->target, sctx->job.diff);
This suggests that the target for Litecoin should be multiplied by 65535. My question is:
- Should the target be scaled by 65535 in the same way?
- Why is this adjustment necessary for Scrypt (Litecoin) but not for Bitcoin?
- How do I correctly calculate the target for Litecoin to avoid getting shares higher than the calculated target?
Any guidance on this would be appreciated!










