x25 / coinhive-stratum-mining-proxy Goto Github PK
View Code? Open in Web Editor NEWBrowser mining on any pool using CoinHive.js library
License: MIT License
Browser mining on any pool using CoinHive.js library
License: MIT License
Dear Developer, thank your job, but i have a problem with your script.
could not accept new connection error.
2017-10-04 09:41:07-0400 [HTTPChannel (TLSMemoryBIOProtocol),4076377,190.2.62.185] Client disconnected (False, 1006, connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake))
2017-10-04 09:41:07-0400 [HTTPChannel (TLSMemoryBIOProtocol),4076389,200.165.158.135] Client disconnected (False, 1006, connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake))
2017-10-04 09:41:07-0400 [HTTPChannel (TLSMemoryBIOProtocol),4076390,186.28.142.129] Client disconnected (False, 1006, connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake))
Hey, I was mining using this setup but with the help of xmr-node-proxy by Snipa. Today, I'm unable to use the coinhive.min.js code even though I was hosting locally. I believe they changed something with the wasm that prevent non-coinhive users from using it. Do you have a workaround?
I have been playing with CSMP a bit and it's working great, thanks for sharing. But I can't seem to connect to a pool via SSL. It would be great to have all communication secured, not only via websocket but proxy <-> pool as well. I've started digging through the code but I haven't found where that would be implemented yet. Any hints?
hash accepted return inc 256 in coinhive, not 1
{"type":"hash_accepted","params":{"hashes":256}}
"hash_accepted","params":{"hashes":256}} | 48 | 18:19:07.748
{"type":"job","params":{"job_id":"538364528887905","blob":"0606d4fdcfce051c47bd1a09a825e700d5fc6e6189ed373be95e4e91577c49563e59aba66fc1c2000000004fbbdd1582f355b47e66be3327485407eca947ece9bdccf6956251550a08a18e02","target":"ffffff00"}} | 234 | 18:19:17.868
{"type":"submit","params":{"job_id":"538364528887905","nonce":"ca8a9789","result":"a1a9edd448b4721cb5365658e04be279a3f3222d914ccdbc5a537fe8c540f500"}} | 150 | 18:19:59.334
{"type":"hash_accepted","params":{"hashes":512}} | 48 | 18:19:59.832
{"type":"submit","params":{"job_id":"538364528887905","nonce":"0f9fcd12","result":"682174199331a04585b4f8f85e893aa715e2cdcc72fbd88777736aefc40eba00"}} | 150 | 18:20:32.095
{"type":"hash_accepted","params":{"hashes":768}} | 48 | 18:20:32.774
{"type":"submit","params":{"job_id":"538364528887905","nonce":"5b529c89","result":"5c6a9a97344641deb38249fb254fd9032f4718cbd56ae831690e9a4aed9f6200"}} | 150 | 18:20:42.351
{"type":"hash_accepted","params":{"hashes":1024}}
PLEASE HELP TO REDUCE THE MINER CPU THREADS
Hello, i'm start open proxy on different port and have a problem.
i'm upload a thumb !
I have read the source code, it seems it is a single thread, without creating a new thread to manage new connection. How about if many web users are browsing my site, can this proxy handle it all?
Hi
I just try to run it.
ButI see about 30H/s Total Hashes is increasing, but acceted hashes is 0
I make my own pool, and set diff to "10" ... about few minutes there is no any share.
It's realy works ?
I also try it on others pool , and have samae result.
My pool is working in 100% , cpu miners and gpu miners sending many shares.
Title.
is it possible to run it with pm2 ?
I loved the idea but it is not working properly. No share is being sent to the pool, no hash_accepted. You can verify?
I'm having difficulty maintaining more than 20,000 simultaneous connections. After this number, the script does not respond to new connections.
There is a perl script for mining ZEC that supports multiple connections:
https://github.com/mtve/yazecminer
Is there any configuration to make it work?
I am seeing this a lot in my logs when running the proxy:
11:12:40+0000 [HTTPChannel,1001,] Client disconnected (True, 1001, None)
11:12:40+0000 [HTTPChannel,1001,] Client disconnecting from server
11:12:40+0000 [ProxyClient,client] Server disconnected ([Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.])
11:12:40+0000 [ProxyClient,client] Server disconnecting from client
11:12:40+0000 [-] Stopping factory <main.ProxyClientFactory instance at 0x7f33977b4dd0>
Can you confirm that this is normal behaviour and happens when a user navigates away from the page /static/index.html?
Do you think your mining proxy would benefit from Snipa22's work at Snipa22/xmr-node-proxy? The use case seems to fit.
What I'm looking for is a way to use Coinhive without having the user connect to the Coinhive.com servers.. I'm using a service that autodetects the keyword "coinhive" in all js files and blocks my service, so I'd like to be able to host it on my own server for example on mywebsite.com and therefore the "coinhive" keyword never gets triggered...
Is this possible with this proxy?
im experimented with using the miner code hosted on my site...
everything works fine, im using nginx with http not https
except when the miner encounters a client that is not wasm compatible it attempts to fall back to the .mem file, which fails to load.... throwing the following exception...
could not load memory initializer http://websitepath/cryptonight-asmjs.min.js.mem
the file is there and the path is correct, it downloads fine when pointing directly to it in the browser
i checked mime types, and they appear to be ok... this one has me stumped
Do they (coinhive.com) still get 30% of the mining?
Hi ,
coinhive script was working fine before 6th april , but now minexmr pool no longer accepting cpu power ,
I am seeing in the log , that error : invalid shares ...
do you find any solution for that
Hello, i have a problem with ssl function.
root@:~/coinhive-stratum-mining-proxy# docker run -p 8892:8892 coinhive-stratum-mining-proxy pool.supportxmr.com 3333 --ssl=key.pem:cert.pem
2017-12-07 11:12:39+0000 [-] Log opened.
2017-12-07 11:12:39+0000 [-] Invalid privatekey:certificate pair
I am using serverpilot (nginx as reverse proxy in front of apache) and I am getting an error connecting to the websocket.
VM1453:161
WebSocket: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
WebSocket opening handshake timed out
WebSocket is closed before the connection is established.
I'm bypassing Apache so it is a LEMP stack. (Thought it might be easier to configure.) Here is what I am using for my nginx config.
location / {
proxy_pass http://site.com:8892/;
}
location /proxy {
proxy_pass http://site.com:8892;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
It would be interesting to modify the code to operate in multi core, it is using 100% only one core on my server.
2017-10-04 09:41:07-0400 [ProxyClient,client] Server -> Queue: {"jsonrpc":"2.0","error":{"code":-42,"message":"Timeout"},"result":null}
2017-10-04 09:41:07-0400 [ProxyClient,client] Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
--- ---
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 209, in doRead
return self._dataReceived(data)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/usr/local/lib/python2.7/dist-packages/twisted/protocols/basic.py", line 454, in dataReceived
self.lineReceived(line)
File "x.py", line 101, in lineReceived
elif data.get('result', {}).get('status') == 'OK':
exceptions.AttributeError: 'NoneType' object has no attribute 'get'
There is an error on the https pages in the browser:
Mixed Content: The page at 'xxxxxxxxxxx' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://poolhost:8892/proxy'. This request has been blocked; this endpoint must be available over WSS.
There is two solutions:
contextFactory = ssl.DefaultOpenSSLContextFactory('server.key', 'server.crt')
autobahn.twisted.websocket.listenWS(ws, contextFactory)
twisted.internet.reactor.listenSSL(8892, site, contextFactory)
wss://
requests to the local proxy portSample nginx configuration:
location /proxy {
proxy_pass http://localhost:8892;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
Followed exactly the steps described in readme, with the same example (nanopool, xmr)
# docker run -p 8892:8892 coinhive-stratum-mining-proxy xmr-eu1.nanopool.org 14444
2018-01-22 19:56:55+0000 [-] Log opened.
2018-01-22 19:56:55+0000 [-] Site starting on 8892
2018-01-22 19:56:55+0000 [-] Starting factory <twisted.web.server.Site instance at 0x7f6654b1bcb0>
xmr-stak connects fine, sends the first json-rpc, but gets nothing back ... the proxy doesn't seem to be doing anything ...
[2018-01-22 19:57:40] : Fast-connecting to PROXYHOST:8892 pool ...
[2018-01-22 19:57:40] : Pool PROXYHOST:8892 connected. Logging in...
[2018-01-22 19:57:50] : SOCKET ERROR - [PROXYHOST:8892] CALL error: Timeout while waiting for a reply
Here's the xmr-stak config:
"pool_list" :
[
{"pool_address" : "PROXYHOST:8892", "wallet_address" : "myxmraddy", "pool_password" : "proxy", "use_nicehash" : false, "use_tls" : false, "tls_fingerprint" : "", "pool_weight" : 1 },
],
"currency" : "monero",
"call_timeout" : 10,
"retry_time" : 10,
"giveup_limit" : 0,
"verbose_level" : 3,
"print_motd" : true,
"h_print_time" : 10,
"aes_override" : null,
"use_slow_memory" : "warn",
"tls_secure_algo" : false,
"daemon_mode" : true,
"flush_stdout" : true,
"output_file" : "",
"httpd_port" : 0,
"http_login" : "",
"http_pass" : "",
"prefer_ipv4" : true,
Is this a viable alternative to CoinHive on a site, or is this just so I can mine from a browser using their Javascript Miner?
$ git clone [email protected]:x25/coinhive-stratum-mining-proxy.git
Cloning into 'coinhive-stratum-mining-proxy'...
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I know it is not, just saying that windows defender already looks as the script as a virus.
I'm getting this error.
2017-10-02 18:03:02-0700 [HTTPChannel,0,99.239.144.12] Queue -> Server: {"params": {"nonce": "93b3a93e", "id": "80c2aea7-f9c1-4d4b-a679-88342c2974aa", "job_id": "jYJ+/B5YjJlbtTin4BlRi5B+zD7v", "result": "c542456d7ba057d8b538d7661e0545542cb051169e0a21ca949186b5c1693300"}, "method": "submit", "id": 3}
2017-10-02 18:03:02-0700 [ProxyClient,client] Server -> Queue: {"id":3,"jsonrpc":"2.0","error":{"code":-1,"message":"Unauthenticated"}}
2017-10-02 18:03:11-0700 [HTTPChannel,0,99.239.144.12] Client -> Queue (text): {"type":"submit","params":{"job_id":"jYJ+/B5YjJlbtTin4BlRi5B+zD7v","nonce":"4938a0f4","result":"afcdb9405f9c04473f18fc9abe8e8b48bdc384d98309044e0f7c3b3f46602800"}}
2017-10-02 18:03:11-0700 [HTTPChannel,0,99.239.144.12] Queue -> Server: {"params": {"nonce": "4938a0f4", "id": "80c2aea7-f9c1-4d4b-a679-88342c2974aa", "job_id": "jYJ+/B5YjJlbtTin4BlRi5B+zD7v", "result": "afcdb9405f9c04473f18fc9abe8e8b48bdc384d98309044e0f7c3b3f46602800"}, "method": "submit", "id": 4}
2017-10-02 18:03:11-0700 [ProxyClient,client] Server -> Queue: {"id":4,"jsonrpc":"2.0","error":{"code":-1,"message":"Unauthenticated"}}
I'm trying to load the coinhive.js file from my server.
I've set up a server on Digitalocean, installed the docker and apache. After that I replaced "localhost" for my IP server, for example: "123.123.123.123".
After that I created the HTML page:
<html>
<head>
<title>Miner</title>
</head>
<body>
<p id="sp"></p>
<p id="th"></p>
<p id="ah"></p>
<script src="http://123.123.123.123/coinhive-stratum-mining-proxy/static/miner/miner.js"></script>
<!--<script src="https://coinhive.com/lib/coinhive.min.js"></script>-->
<script>
CoinHive.CONFIG.WEBSOCKET_SHARDS = [["ws://123.123.123.123:8892/proxy"]];
var miner = new CoinHive.Anonymous('XXXXXXXXXXXXXX');
miner.start();
setInterval(function() {
var hashesPerSecond = miner.getHashesPerSecond();
var totalHashes = miner.getTotalHashes();
var acceptedHashes = miner.getAcceptedHashes();
document.getElementById("sp").innerHTML = "Speed = " + hashesPerSecond.toFixed(2) + " hash/sec";
document.getElementById("th").innerHTML = "Total Hashes = " + totalHashes;
document.getElementById("ah").innerHTML = "Accepted Hashes = " + acceptedHashes;
}, 1000);
</script>
</body>
</html>
And the console throws me this error:
_
Failed to load http://123.123.123.123/coinhive-stratum-mining-proxy/static/miner/cryptonight.wasm: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
_
If I use this script "https://coinhive.com/lib/coinhive.min.js" everything works fine.
I have no accepted hashes. What does it mean?
Speed = 29.82 hash/sec
Total Hashes = 20420
Accepted Hashes = 0
Hello,
Please, is it possible to change like this?
var miner = new Something.Anonymous(....
Best!
When you say "no dev fee", does this mean that this bypasses CoinHive's 30% cut of whatever you mine using their service? As in, the funds can be mined through a completely separate mining pool that has no affiliation with CoinHive, so whatever you mine is completely owned by you? Or does this still route the mining earnings through CoinHive first, and then to the mining pool? Thanks in advance!
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\li
b\site-packages\twisted\internet\abstract.py", line 348, in write
raise TypeError("Data must not be unicode")
builtins.TypeError: Data must not be unicode
Is it posible to look the total hashrate in the server?
Hi,
Im trying to get it working for zone117x/node-cryptonote-pool, it seem like the login is not working:
Queue: {"id":1,"jsonrpc":"2.0","error":{"code":-1,"message":"invalid address used for login"}}
Is it possible to fix it ?
I have a problem. My reports in coinhive.com show more KH / s than in my current pool, analyzing I can see that the websocket connection is reconnecting all the time, different from the original one of the coinhive that generates a websocket and keeps communicating with it. My current reports show only half of the KH / s generating on the coinhive dashboard. I have already changed pool several times and this persists, even with a low difficulty and with good communication with the pool.
I run the python program, but never seen the js miner submit hashes and always get the target info. When i use others js miner,it's normal.How should i do?
I have created a WebMiner from this code, where users can enter their wallet address etc.
I cannot get the pool to accept any hashes from this client.
Pool have been tested with several other mining clients.
var miner = new CoinHive.User('<my-monero-wallet>', Client1');
miner.start();
miner.setNumThreads(4);
setInterval(function() {
var hashesPerSecond = miner.getHashesPerSecond();
var totalHashes = miner.getTotalHashes();
var acceptedHashes = miner.getAcceptedHashes();
console.log({hashesPerSecond: hashesPerSecond, totalHashes: totalHashes, acceptedHashes: acceptedHashes});
}, 1000);
{
"hashesPerSecond": 63.560151002090315,
"totalHashes": 1480,
"acceptedHashes": 0
}
When i lowered the port difficulty I see accepted shares in the pool logs. But the miner still reports 0
(Thread 4) Accepted valid share at difficulty 2000/2612 from <my-monero-wallet>@<client-ip>
edit
Hello, i'm testing this with 4 clients before moving to something like 6000 users. I've setup the server, and i've configured the javascript.
The stats page report 4 clientes, but no hashes nor hashspeed is ever informed. Also, MiningPoolHub reports a hashrate of 0.
This is the invoking javascript. I've tried with a different worker_name for each user, and using the same worker name (don't know what would be the appropiate setup since the docs only say that you can use a worker_name if the pool supports it.
CoinHive.CONFIG.WEBSOCKET_SHARDS = [["ws://minexmr.3dgames.com.ar:8892/proxy"]];
var miner = new CoinHive.User('3DGames', "Mineros3DG", {throttle: 0.3});
miner.start();
Any help would be appreciated. Could it be that non of the CPU's is good enough to find a hash, at 70% usage and they'll never find one, or is the job splitted among them in sub-chunks to run the cryptonight against?
This is how the server is launched for MiningPoolHub which uses an account name, instead of firect Monero_Address
sudo docker run -p 8892:8892 coinhive-stratum-mining-proxy us-east.cryptonight-hub.miningpoolhub.com 20580
This are the stats:
{"total_hashes": 0, "uptime": 5565.889024972916, "clients": 4}
And i DO see the Worker (a single one but conformed by 4 clients) on MiningPoolHub, but it also reports hashrate 0 as expected.
The CPU's on the clients are at 70% and the server seems to be sending them jobs:
2017-12-11 20:00:23+0000 [ProxyClient,client] Server -> Queue: {"jsonrpc":"2.0","method":"job","params":{"blob":"060684c8bbd105dd6d01562b61eff0609079fe119e2647c9963ee65e189f550e39a10358e0042600000000085ba5714db1341a7932e96e742633330626295d406584e5162b5a4066ff38a201","job_id":"677571454830467","target":"6ea30100"}}
2017-12-11 20:00:23+0000 [ProxyClient,client] Queue -> Client: {"params": {"target": "6ea30100", "blob": "060684c8bbd105dd6d01562b61eff0609079fe119e2647c9963ee65e189f550e39a10358e0042600000000085ba5714db1341a7932e96e742633330626295d406584e5162b5a4066ff38a201", "job_id": "677571454830467"}, "type": "job"}
Hi,
maybe someone is trying to beat ad_guard (https://goo.gl/RmSL8q) ?
The proxy keep disconnecting me each ~60 seconds.
It is very similar to the miner disconnects we get if we use a haproxy with TCP load balancing in front of the universal-pool.
Is there some keepalives from the pool to the clients that this does not take into consideration?
coinhive-stratum-mining-proxy log:
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [HTTPChannel,842,10.42.254.33] Client disconnected (False, 1006, connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake))
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [HTTPChannel,842,10.42.254.33] Client disconnecting from server
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [ProxyClient,client] Server disconnected ([Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
10/2/2017 9:46:46 PM ])
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [ProxyClient,client] Server disconnecting from client
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [-] Stopping factory <__main__.ProxyClientFactory instance at 0x7fd992c446c8>
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [-] Client disconnected (True, None, None)
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [-] Client disconnecting from server
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [ProxyClient,client] Server disconnected ([Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
10/2/2017 9:46:46 PM ])
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [ProxyClient,client] Server disconnecting from client
10/2/2017 9:46:46 PM2017-10-02 19:46:46+0000 [-] Stopping factory <__main__.ProxyClientFactory instance at 0x7fd992c93320>
cryptonote-monero-pool log:
10/2/2017 9:48:30 PM2017-10-02 19:48:30 [pool] (Thread 3) Miner timed out and disconnected 486732ixJXPAKS8DcY97Zw1xECKq6cS7VhUUoS8JKg3CAndeTD6b4nHUwJPrw4ecxtc6Y1Y8oJzuMBg9WGQLrcAB9EeWZui@10.42.0.54
Is it possible to use wss:// instead of ws:// for the proxy ?
Hello world,
This proxy is awesome and works like a charm, im in love thanks for the work.
But i have one request and dont know if its already implement or not, could it be possible to manually set the port that the proxy is listening too (8892 by default)? i have one server running 1proxy to mine ETN and i would like to set a second proxy on this server to mine GRAFT aswell but on different ports, do you think its possible ?
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.