Bitcoin Forum
December 11, 2017, 06:04:38 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: C++ --- How to send a request to a Bitcoin mining pool for Block header  (Read 422 times)
BigManComputer
Newbie
*
Offline Offline

Activity: 2


View Profile
August 23, 2017, 10:47:50 PM
 #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
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
1512972278
Hero Member
*
Offline Offline

Posts: 1512972278

View Profile Personal Message (Offline)

Ignore
1512972278
Reply with quote  #2

1512972278
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1246


17kKQppUsngUiByDsce4JXoZEjjpvX9bpR


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
Newbie
*
Offline Offline

Activity: 2


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:  

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!