Bitcoin Forum
May 25, 2024, 02:11:00 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: miner client - just to understand mining  (Read 3921 times)
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6653


Just writing some code


View Profile WWW
March 03, 2017, 02:08:41 PM
 #21

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:

Code:
{"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:
Code:
Data:
00000002 fc517a2df2b283474b135215a00604af276318262f5eebc00000043100000000 db9fcfcc3781c1342c2750214e46407286cbf29985e688d0392e6b8005c4c824 5032580a 1a07a85e 00000000 000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000

Target:
ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000

We also know that the right solution is:  (nonce = 0x8e631c12)
Code:
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 Sad

Where's the mistake?  Or:  where are the mistakes? Smiley
What block are you trying to replicate? Check your endianess, almost everything in Bitcoin is little endian so you might have some errors there.

Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!