Author

Topic: C++ --- How to send a request to a Bitcoin mining pool for Block header (Read 566 times)

newbie
Activity: 2
Merit: 1
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...
staff
Activity: 3458
Merit: 6793
Just writing some code
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.
newbie
Activity: 2
Merit: 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
Jump to: