Bitcoin Forum
November 19, 2017, 06:23:23 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Stratum-Client Mining Bitcoin Worked Example  (Read 337 times)
MSD12
Newbie
*
Offline Offline

Activity: 1


View Profile
November 04, 2017, 11:55:08 PM
 #1

Hello World! I'm trying to write my own mining client for bitcoin. I'm having trouble verifying if my implementation is correct mainly because I'm finding mixed information between bitcoin and scrypt and a lack of complete worked examples. Can someone please verify my calculations and let me know if I am going wrong anywhere. I'm sure this would be very helpful for others as well having the same issue. I've followed these articles:

http://www.righto.com/2014/02/bitcoin-mining-hard-way-algorithms.html
https://slushpool.com/help/manual/stratum-protocol

I'm using Slush Pool Stratum server at stratum.slushpool.com:3333

Here is the data received from the server:

{"result":[[["mining.set_difficulty","1"],["mining.notify","1"]],"036502007b22ba",4],"error":null,"id":1}

{"params":[2048],"method":"mining.set_difficulty","id":null}

{"params":["b8d68","cbf39a1c176dd70ed982702cb447faf5015c6842006ce98f0000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff4503228607fabe6d6d5f5e8246e265a6e792affe45ec347a9893ac01fd0c4a25136e4e1b4bee f44bee0100000000000000","688d0b2f736c7573682f0000000002a260c452000000001976a9147c154ed1dc59609e3d26abb2d f2ea3d587cd8c4188ac0000000000000000266a24aa21a9ed411aab825f840f3f1b5d5582d70b11 c12f08874d5b4ddaf3aa0e7144515d804200000000",["ea03b95b38e7fc628e02c86c34650f47b28b931a70ab91146362396c5c46b70a","5bfac7bf58ee2216961e9b6d5b20f5bfbca2c7c58f8ea68a5ceee0c2a90e04ed","f01ea5a26c625454104441d1979a09ccaf19d451c94a2d94ec590a1464a18887","3050aca4d1ea84238cd0c3a82d9db130cb056d9c280bfd10b3e6cffb9bfd0a03","0bdbcf4179424b9a27a0a83af455bfd2e590faa793d0d6bc323d8a39b88c718f","4066ffde337ad7d3e88e81c006d6d0f5772f65cbd05c1b5dde466d09b3729102","a23b95ce92563d19c4aa5c56d7656eb929cfe491a9a544aca2454da10d6607f8","3b6b97e6fa8badd5a9c3438091d045c8b4750b97d978ad94b6ca679878266651","af2845d881fa472ba9efb244d947df2de2ccdb362f83aff6357c1124ed6ffefc","8e0ed1e6ea27d5ee9e627810eeeaae82267e6ecf6ba2f8560c06719ab1f1c415","b37524607ccf37c3ac17209d1949314d2def88b9571e23752cadbaee7bd0ff5f"],"20000000","1800c1bd","59fe2816",true],"method":"mining.notify","id":null}

Here is my calculations on the above data:

pDiff
0x00000000001fffe0000000000000000000000000000000000000000000000000

nDiff
0x000000000000000000c1bd000000000000000000000000000000000000000000

extraNonce2
0x00000000

coinBase
01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff4503228607fabe6d6d5f5e8246e265a6e792affe45ec347a9893ac01fd0c4a25136e4e1b4bee f44bee0100000000000000036502007b22ba00000000688d0b2f736c7573682f0000000002a260c 452000000001976a9147c154ed1dc59609e3d26abb2df2ea3d587cd8c4188ac0000000000000000 266a24aa21a9ed411aab825f840f3f1b5d5582d70b11c12f08874d5b4ddaf3aa0e7144515d80420 0000000

coinBaseHash
923667d89ce61a05f6a5d43671af7fea617053d64d4a3299c8140fd00465a790

merkleRoot
ef301228ae3183b3a8a50d6cc105062ab450eb2a73ab5062b496913f0a19fe09

nonceUsed = 0

blockHeader
000000201c9af3cb0ed76d172c7082d9f5fa47b442685c018fe96c00000000000000000009fe190 a3f9196b46250ab732aeb50b42a0605c16c0da5a8b38331ae281230ef1628fe59bdc10018000000 00

hash (bytes reversed for comparing with pDiff for submitting shares or nDiff if solo mining)
7741e4ef871fb3f3eb10b36efbc3b74bebc35cc0261c0ace2452e19be99ad685
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!