TigerND / node-stratum-proxy

Simple node.js stratum proxy
MIT License
10 stars 11 forks source link

Change the workername and password on the fly #1

Open anemol opened 6 years ago

anemol commented 6 years ago

For some reason, i need to change the worker's name & password on the fly.

I tried to intercept mining.authorize and mining.submit methods but the miner program (minerd) doesn't want to work normally.

 self.socket.on('data', function(data) 
    {
        var json=JSON.parse(data.toString());
        if (json.method=='mining.authorize')
        {
            json.params[0]='newWorker';
            json.params[1]='x';
            self.onServerData(Buffer.from(JSON.stringify(json)));
        }
        else if (json.method=='mining.submit')
        {
            json.params[0]='newWorker';
            self.onServerData(Buffer.from(JSON.stringify(json)));
        }
        else  
            self.onServerData(data);
    });

Any idea how to do this feature?

anemol commented 6 years ago

Finally found the problem. Have to add a \n

self.onServerData(Buffer.from(JSON.stringify(json))+'\n');