Thanks for stopping in :)
I break things, fiddle around, and then try to put them back together.
It is how I seem to learn best.
(One of) My recent obsession(s) has been with crypto-currency.
Since I have a little bit of knowledge working with API's through PHP and cUrl, I decided to use PHP for my fiddling.
So, I tell myself, "Why not register with a popular pool and see if I can't examine what a piece of 'work' looks like. Simple!"
I'm well aware that PHP, Json-RPC and CPU Bitcoin mining are extremely inefficient. I am not attempting to really create anything that will see the light of day; simply fiddling for fiddling's sake.
Evidently, I am just a bit ignorant on how Json-RPC and Stratum servers operate. I had thought to post this to the Bitcoin specific exchange, however I have the feeling my mistake is much more elementary than that.
The Goal: Get some work and print it to the page so I can inspect it and hopefully learn something.
My Attempt:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
function tickleElmo () {
$feed = 'http://stratum.btcguild.com';
$post_string = '{"method": "getblocktemplate", "params": [], "id": "0"}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feed);
curl_setopt($ch, CURLOPT_PORT, 3333);
curl_setopt($ch, CURLOPT_USERPWD, "elmoworker_1:123");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/stratum', 'Content-length: '.strlen($post_string)));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json', 'Content-length: '.strlen($post_string)));
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$data = tickleElmo();
var_dump($data);
?>
So, I had assumed (obviously incorrectly) that simply making a POST to the end-point would yield at least some response. I can ping the server stratum.btcguild.com
just fine. Yet, via cUrl I don't get anything at all... the script simply times out and returns false
.
I have tried a few different Content-type
's, adding a newline character to the end of the post, the getwork
and getblocktemplate
methods inside the $post_string
, and about 2 dozen other hack and slash alterations :(
I believe that the problem lies in my understanding of Json-RPC, as I have only previously worked with simple get
API end-points in the past, but I have done my personal best to read up and find a simple explanation and have hit a road-block. I just don't have the tools to understand... :(
Any thoughts or additional sources of research/information from the intelligent folks here @stackoverflow would be greatly appreciated,
Samantha.