Bitcoin Forum
May 11, 2024, 01:18:03 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: C++ --- How to send a request to a Bitcoin mining pool for Block header  (Read 544 times)
BigManComputer (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
August 23, 2017, 10:47:50 PM
Merited by ABCbits (1)
 #1

Hey! This has had me stumped for a while. I am quite new to networking in c++, however, I do have fundamental knowledge.

I was wondering how exactly I send a request to a Bitcoin mining pool to request block header information from a pool in c++. I have done much research myself into this, and so far haven't found a solution. I would prefer to use the newer Getblocktemplate protocol, however, I am fine with an answer regarding the Getwork protocol.

I am aware I must send a request to a pool, in the form of a JSON snippet, and the server will respond with the current Block's information, also in the form of a JSON snippet. A have received this information from  here: https://en.bitcoin.it/wiki/Getblocktemplate    and from many other sources, however, nobody explicitly said how to send a request to the pool, and no examples of c++ code were given.

If somebody could help me I would greatly appreciate it...
Thanks  Smiley
1715390283
Hero Member
*
Offline Offline

Posts: 1715390283

View Profile Personal Message (Offline)

Ignore
1715390283
Reply with quote  #2

1715390283
Report to moderator
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715390283
Hero Member
*
Offline Offline

Posts: 1715390283

View Profile Personal Message (Offline)

Ignore
1715390283
Reply with quote  #2

1715390283
Report to moderator
1715390283
Hero Member
*
Offline Offline

Posts: 1715390283

View Profile Personal Message (Offline)

Ignore
1715390283
Reply with quote  #2

1715390283
Report to moderator
1715390283
Hero Member
*
Offline Offline

Posts: 1715390283

View Profile Personal Message (Offline)

Ignore
1715390283
Reply with quote  #2

1715390283
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
August 23, 2017, 11:24:53 PM
 #2

There are two main protocols used for getting block information, stratum and getblocktemplate. For either one, you have to connect to the url for a pool's stratum or getblocktemplate server. Then from there you follow the respective protocol to request data from the server.

Information on how to use the stratum protocol is found here: https://slushpool.com/help/manual/stratum-protocol
Basically you just open up a tcp connection and send it specific JSON data and you will get a reply. You can do this manually by using netcat.

Information on how to use getblocktemplate can be found here: https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki and https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki
Basically you just connect to the server and send it HTTP POST requests.

BigManComputer (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
August 24, 2017, 09:29:40 AM
 #3

Thanks for the reply! Smiley
I had an idea that remote procedure calls may have been involved...
I will look into this when I get back to my computer...
Pages: [1]
  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!