OK, OK, don't yell at me. I know this topic is really old.
But I was hoping someone here will be able to give me some help.
I tried to implement my own miner (just to understand mining).
I implemented it using getwork (I know it's old, but it was simpler for me)
so to check that it works I used the same example as here:
{"hash1"=>"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", "target"=>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000", "submitold"=>true, "identifier"=>"91138", "data"=>"00000002fc517a2df2b283474b135215a00604af276318262f5eebc00000043100000000db9fcfcc3781c1342c2750214e46407286cbf29985e688d0392e6b8005c4c8245032580a1a07a85e00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000", "midstate"=>"03ad4305c1cad2bf14a99b82f3557b5722a060d6ac207450e939cb9f8143a605"}
Or in a more human-readable format the essence of this is the data and the target:
Data:
00000002 fc517a2df2b283474b135215a00604af276318262f5eebc00000043100000000 db9fcfcc3781c1342c2750214e46407286cbf29985e688d0392e6b8005c4c824 5032580a 1a07a85e 00000000 000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000
Target:
ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000
We also know that the right solution is: (nonce = 0x8e631c12)
Solution:
00000002 fc517a2df2b283474b135215a00604af276318262f5eebc00000043100000000 db9fcfcc3781c1342c2750214e46407286cbf29985e688d0392e6b8005c4c824 5032580a 1a07a85e [b]8e631c12[/b]
000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000
The Nounce that I get is:
0x000141D0
And the hash of the binary data that I get is:
"0000075B2D7B45479BDE7D0A073900AE825F69C9FF16084CF83BB45B4F7B63C9"
Target to compare with:
"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
Result: BAD NEWS: the calculated nounce is different and the hash is greater than the target
Where's the mistake? Or: where are the mistakes?
What block are you trying to replicate? Check your endianess, almost everything in Bitcoin is little endian so you might have some errors there.