Write NiceHash bot, make lots of profit

Maznoz
Archived posts: 27
Joined: Sep 03, 2015

Re: Write NiceHash bot, make lots of profit

by Maznoz · · Post #3777

Hi Steve,

I've tried to connect to both:
  • wss://live.prohashing.com:443/ws
  • wss://prohashing.com:444/ws
the first location is specified in the help documentation and the second location was used in the example you provided earlier in this thread. Both have the same authentication issue, as written in my earlier reply.

Best,
Maznoz
Steve Sokolowski avatar
Steve Sokolowski
Archived posts: 4559
Joined: Aug 27, 2014

Re: Write NiceHash bot, make lots of profit

by Steve Sokolowski · · Post #3779

The port 444 one is definitely incorrect and will be removed from the documentation in the next release.

I don't understand what is going on here with the other one. The website has no problems connecting to the server, and that code comes directly from the website. I'm going to ask Chris to look into this and see if he can provide any more information.
JoeTheMiner
Archived posts: 64
Joined: Nov 19, 2014

Re: Write NiceHash bot, make lots of profit

by JoeTheMiner · · Post #3786

Steve Sokolowski wrote:The port 444 one is definitely incorrect and will be removed from the documentation in the next release.

I don't understand what is going on here with the other one. The website has no problems connecting to the server, and that code comes directly from the website. I'm going to ask Chris to look into this and see if he can provide any more information.
Ok, that sounds good. I am not for sure either because it should be working if the code is the same.
Chris Sokolowski avatar
Chris Sokolowski
Site Admin
Archived posts: 945
Joined: Aug 27, 2014

Re: Write NiceHash bot, make lots of profit

by Chris Sokolowski · · Post #3788

Are you getting a security certificate error? I know that Internet Explorer 10 doesn't like our wamp security certificate and won't display live data because of it, but since IE10 is such a small portion of the market, I have not looked into correcting it. If this same issue also affects your usage, I will try to correct the certificate issue.
Maznoz
Archived posts: 27
Joined: Sep 03, 2015

Re: Write NiceHash bot, make lots of profit

by Maznoz · · Post #3789

Hi Chris,

I indeed got a certificate error, but disabled certificate verification while testing. So this issue does not seem to be caused by certificate issues.

My python code, which works for the poloniex wamp api (no authentication needed there), is as follows:

Code:

#!/usr/bin/env python3

import ssl
from autobahn.asyncio.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationRunner
from autobahn.wamp import auth
try:
    import asyncio
except ImportError:
    # Trollius >= 0.3 was renamed
    import trollius as asyncio

user = "web"
secret = "wampUser"

class ProhashingComponent(ApplicationSession):
    def onConnect(self):
        self.join(self.config.realm, [u"wampcra"], user)

    def onChallenge(self, challenge):
      if challenge.method == u"wampcra":
         print("WAMP-CRA challenge received: {}".format(challenge))

         if u'salt' in challenge.extra:
            # salted secret
            key = auth.derive_key(secret,
                                  challenge.extra['salt'],
                                  challenge.extra['iterations'],
                                  challenge.extra['keylen'])
         else:
            # plain, unsalted secret
            key = secret

         # compute signature for challenge, using the key
         signature = auth.compute_wcs(key, challenge.extra['challenge'])

         # return the signature to the router for verification
         return signature

      else:
         raise Exception("Invalid authmethod {}".format(challenge.method))

    @asyncio.coroutine
    def onJoin(self, details):
        def onProfitabilityUpdates(*args):
            print("Profitability Updates event received:", args)

        try:
            yield from self.subscribe(onProfitabilityUpdates, 'profitability_updates')
        except Exception as e:
            print("Could not subscribe to topic:", e)

def main():
    context = ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE

    runner = ApplicationRunner(u"wss://live.prohashing.com:443/ws", u"mining", ssl=context)
    #runner = ApplicationRunner(u"wss://prohashing.com:444/ws", u"mining", ssl=context)

    runner.run(ProhashingComponent)

if __name__ == "__main__":
    main()
The wampcra imlementation comes straight from the autobahn examples.

Hope this helps.

Best,
Maznoz
Steve Sokolowski avatar
Steve Sokolowski
Archived posts: 4559
Joined: Aug 27, 2014

Re: Write NiceHash bot, make lots of profit

by Steve Sokolowski · · Post #3790

Hi Maznoz,

There is at least one error in this code - the password was translated incorrectly from the Javascript. You'll notice the line that sets the password equal to the username variable, not equal to the variable name (which you have as a string - "wampUser.") The password, like the username, is "web."

Thanks,

-Steve


Maznoz wrote:Hi Chris,

I indeed got a certificate error, but disabled certificate verification while testing. So this issue does not seem to be caused by certificate issues.

My python code, which works for the poloniex wamp api (no authentication needed there), is as follows:

Code:

#!/usr/bin/env python3

import ssl
from autobahn.asyncio.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationRunner
from autobahn.wamp import auth
try:
    import asyncio
except ImportError:
    # Trollius >= 0.3 was renamed
    import trollius as asyncio

user = "web"
secret = "wampUser"

class ProhashingComponent(ApplicationSession):
    def onConnect(self):
        self.join(self.config.realm, [u"wampcra"], user)

    def onChallenge(self, challenge):
      if challenge.method == u"wampcra":
         print("WAMP-CRA challenge received: {}".format(challenge))

         if u'salt' in challenge.extra:
            # salted secret
            key = auth.derive_key(secret,
                                  challenge.extra['salt'],
                                  challenge.extra['iterations'],
                                  challenge.extra['keylen'])
         else:
            # plain, unsalted secret
            key = secret

         # compute signature for challenge, using the key
         signature = auth.compute_wcs(key, challenge.extra['challenge'])

         # return the signature to the router for verification
         return signature

      else:
         raise Exception("Invalid authmethod {}".format(challenge.method))

    @asyncio.coroutine
    def onJoin(self, details):
        def onProfitabilityUpdates(*args):
            print("Profitability Updates event received:", args)

        try:
            yield from self.subscribe(onProfitabilityUpdates, 'profitability_updates')
        except Exception as e:
            print("Could not subscribe to topic:", e)

def main():
    context = ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE

    runner = ApplicationRunner(u"wss://live.prohashing.com:443/ws", u"mining", ssl=context)
    #runner = ApplicationRunner(u"wss://prohashing.com:444/ws", u"mining", ssl=context)

    runner.run(ProhashingComponent)

if __name__ == "__main__":
    main()
The wampcra imlementation comes straight from the autobahn examples.

Hope this helps.

Best,
Maznoz
Last edited Wed Jul 27, 2016 06:37 PM UTC by Steve Sokolowski; edited 1 time(s).
JoeTheMiner
Archived posts: 64
Joined: Nov 19, 2014

Re: Write NiceHash bot, make lots of profit

by JoeTheMiner · · Post #4225

Steve Sokolowski wrote:Good morning!

We're proud to finally document our WAMP API, which allows users to obtain live statistics about the status of the pool. In the coming days, we also plan to provide methods that provide insight into users' workers and balances.

The first methods are now available at https://prohashing.com/help.html#api-wamp.

For the first time, these methods make it possible for a user to write a "NiceHash bot." Since NiceHash provides an API with all the necessary properties and methods, a bot can be written to obtain pricing at NiceHash, compare it to profits provided by the WAMP API here, and if profit here is greater, then buy lots of hashrate from NiceHash and direct it here.

If programmed conservatively, this bot should never be at risk of losing money. During times of high profitability, profits here often soar to 33% above NiceHash. That should never happen, because a bot like this can drive a significant portion of NiceHash's hashrate here during those times up to the point that NiceHash's rate equalizes.

Is anyone interested in writing this bot? We aren't asking for any cut of the profits that you earn; we just want someone to write it and run it to make themselves money so that we can take the pool fees. GenTarkin seems to have the expertise to make a lot of profit by doing this.
Hi Steve,

Just wanted to give you an update that I finally finished my bot tonight and have started it up. So you should start seeing more hashrate from me now!

Thanks,
Joseph