Hello there, everyone,
For the past few days, I have been working on a new project. Because I wanted to learn more about how the Bitcoin works internally, I decided to give it a go and create my own miner. But not just an ordinary miner, no, something slightly different.
I present you:
CurlyBrace, the first JS/PHP Miner(Disclaimer: As of now, this is a proof-of-concept. Altough the code works as-is, it is not fully finished yet, and doesn't yet mine real bitcoins)
Some basic info:Language: PHP, and JavaScript for the front-end(steering wheel) of the miner.
Type: CurlyBrace uses the getblocktemplate standard.
Speed: Slow(0.1Mhash/s), but will hopefully allow paralellization in the future by talking to multiple webservers at once.
Why this odd language choice?Using PHP, a serverside web programming language has certain interesting characteristics, and I was interested to see how well it would perform.
Pros:-You now have some use for the normally unused processing power you have in your monthly server subscription.
-You don't have to pay for electricity costs during hashing on a remote computer.
-Opens up the possibility of setting up many servers (e.g. using free web hosting) in parallel, without much effort/costs.
Cons:-Hashing is of course not fast. Tests thus far return about 0.1Mhash/s per slave webserver.
-Your worker username and password are visible by websites you are using. When using a cross-site AJAX solution, this data is even more visible.
What does the code do right now?-You visit the webpage with the javascript client on it.
-Client sends a fake request(no communication with a pool yet) to the server, asking it to hash until it finds a hash below the target.
-Server hashes until it finds a hash below the target or it has tried 1000000 hashes(0.1Mhash). Returns results back to client.
-Client shows the debug info the server returned.
-If no correct solution is found yet, client sends a new request, but with an incremented nonce.
-Etc.
-If a correct solution is found, client displays the solution on the page.
What still needs to be done?-Talking to an actual pool
-Support to increment the extra nonce (change the coinbase) when all 32int nonce values have been tried.
-Enforcing that the correct block version is used.
-Support for the optional parts of the getblocktemplate specification.
-Support for paralellization, i.e. talking to multiple server-slaves at the same time from one javascript client.
-Bugfixing. Lots of it.
-Possiblility implementing a scrypt algorithm as well?
Why the need for a client webpage to operate the miner?1. PHP when executed is synchronious, JavaScript on a web page is not. This allows paralellization(talking to multiple servers at once) when using JavaScript in the client side.
2. Very easy to start and stop.
3. I've had trouble getting cURL to work in PHP with ports different than port 80(which is the default HTTP web page port, but is almost never used for a bitcoin mining address).
Also, many PHP hosts don't allow cURL to be used at all.
Thus, using Javascript together with an Ajax Cross Domain service (such as
YQL) seems like a better option.
Can I try this myself?Yes, you can
download the source here, upload it to your webserver and direct your browser to bitfrontend.html
Alternatively, you can currently see the script working
here.
Why do you post this here in such an early stage of development?I have a couple of questions, and I hope someone can answer them:
1. Is my hashing calculation correct? Is the way I assemble the header correct?
2. The reasons to change the coinbase are unclear to me. The wiki is kind of confusing on this matter. Could someone elaborate?
I will be developing this project further during the next couple of weeks. But if there is anyone interested in contributing, feel free. There's a lot of optimizing and cleaning up to do ^_^'.
Thank you very much for your time. If you like, you can thow a few coins in my direction:
1MUZQsCSifF27XX98W13JLz6E9YaU3mVqG .
Have a great day!
~W-M