ESP32-Bitcoin icon indicating copy to clipboard operation
ESP32-Bitcoin copied to clipboard

Connecting to Mining Pool (solo lottery using https://solo.ckpool.org/)

Open nikk16 opened this issue 4 years ago • 4 comments

Would you or any one else add the Pool Mining option to the code please?

I was gonna use https://solo.ckpool.org/ which can be used for solo mining by connecting to it like any other pool. With this we dont need to run a full node. I have an ESP running 24x7 and was hoping to add the mining algorithm to it as lottery.

nikk16 avatar Aug 12 '20 13:08 nikk16

Let me calculate the probabilities again: One ESP does 24E3 H/s = 756E9 H/year (running constantly). Average block time did not change much, but the network hash rate increased to 120E18 H/s, that is 3 times more than when I wrote the post and made this. So its now 600*120E18 = 72E21 Hashes per Block in average. Gives a overall probability to hit a block of 1 vs 10E12. A usual lottery ticket has a probability of about 1 vs 14 million (14E6) to hit the jackpot. After all we could say that one lottery ticket is equal to running that ESP more than 700 000 years! So I would strongly suggest to just buy a lottery ticket instead ;) I have also a few ESPs running all the time, but implementing that is just not worth it for me personally. I am happy to accept pull requests though, if you (or someone else) is willing to make it for fun. It could also be a nice first project to get experience with the stratum protocol.

Jakeler avatar Aug 12 '20 13:08 Jakeler

I was hoping if its not a lot of work you or someone could add Pool Mining to the existing hash code. I know the probability is astronomically low, i wanna add the code to learn and have fun. I have an ESP running 24x7 anyway, controlling my room lights. So I was gonna add the mining code to it.

nikk16 avatar Aug 12 '20 14:08 nikk16

Im looking through https://github.com/ckolivas/cgminer/blob/master/cgminer.c but i dont understand most of it.

nikk16 avatar Aug 29 '20 14:08 nikk16

The cgminer code uses many functions/syscalls from Unix and libraries like curl, which makes it not easily portable to an ESP anyway. It probably makes more sense to write it from scratch in C++. I would suggest looking at the protocol description and making it based on that: https://en.bitcoin.it/wiki/Stratum_mining_protocol https://github.com/aeternity/protocol/blob/master/STRATUM.md First try to get JSON-RPC working, the ESP32 Arduino framework already provides a HTTP client implementation and there is ArduinoJSON to help with the serialization and response parsing. So it should not be too hard with these building blocks, but quite a bit of work for sure.

Jakeler avatar Aug 29 '20 16:08 Jakeler