Bitcoin mining algorithm - target - Java

1

Default share difficulty is 1 (big-endian target for difficulty 1 is 0x00000000ffff0000000000000000000000000000000000000000000000000000)

How to calculate this?
How it look like on Java code?
What algorithm of calculate this value?

Oleg D

Posted 2016-07-27T19:08:54.840

Reputation: 45

Answers

1

The difficulty is a part of the block header called "bits". It is the 72nd to 75th bytes of the block header and looks like this in hex:

bits = 0x76270618

Remember this is little-endian! Actual big-endian version is 0x18062776 Take the first byte as the “exponent” and the other three bytes as the “coefficient”

Exponent = 0x18 = 24

Coefficient = 0x062776

Plug into this formula:

Coefficient * 2**(8*(Exponent - 3)) = 0x0000000000000000062776000000000000000000000000000000000000000000

And that's how you can calculate difficulty from bits.

Jimmy Song

Posted 2016-07-27T19:08:54.840

Reputation: 7 067