Write NiceHash bot, make lots of profit

News updates about the Prohashing pool
Forum rules
The News forum is only for updates about the Prohashing pool.

Replies to posts in this forum should be related to the news being announced. If you need support on another issue, please post in the forum related to that topic or seek one of the official support options listed in the top right corner of the forums page or on prohashing.com/about.

For the full list of PROHASHING forums rules, please visit https://prohashing.com/help/prohashing- ... rms-forums.
Maznoz
Posts: 27
Joined: Thu Sep 03, 2015 6:02 am

Re: Write NiceHash bot, make lots of profit

Post by Maznoz » Tue Jul 26, 2016 2:12 am

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
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: Write NiceHash bot, make lots of profit

Post by Steve Sokolowski » Tue Jul 26, 2016 9:13 am

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
Posts: 64
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Post by JoeTheMiner » Tue Jul 26, 2016 10:00 pm

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.
User avatar
Chris Sokolowski
Site Admin
Posts: 945
Joined: Wed Aug 27, 2014 12:47 pm
Location: State College, PA

Re: Write NiceHash bot, make lots of profit

Post by Chris Sokolowski » Tue Jul 26, 2016 11:51 pm

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
Posts: 27
Joined: Thu Sep 03, 2015 6:02 am

Re: Write NiceHash bot, make lots of profit

Post by Maznoz » Wed Jul 27, 2016 2:48 am

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: Select all

#!/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
User avatar
Steve Sokolowski
Posts: 4585
Joined: Wed Aug 27, 2014 3:27 pm
Location: State College, PA

Re: Write NiceHash bot, make lots of profit

Post by Steve Sokolowski » Wed Jul 27, 2016 7:51 am

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: Select all

#!/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 by Steve Sokolowski on Wed Jul 27, 2016 2:37 pm, edited 1 time in total.
Maznoz
Posts: 27
Joined: Thu Sep 03, 2015 6:02 am

Re: Write NiceHash bot, make lots of profit

Post by Maznoz » Wed Jul 27, 2016 9:27 am

Hi,

the connection seems to work now. I'm not receiving any profitability updates, but I'll start debugging that.
Thanks for the help so far.

Best,
Maznoz
kenedy
Posts: 1
Joined: Sun Oct 16, 2016 3:46 am

Re: Write NiceHash bot, make lots of profit

Post by kenedy » Sun Oct 16, 2016 3:47 am

That's great news and you have done great job.well done
Graduated from Soran [CENSORED] with First Class Degree with Honours in Computer Science.
JoeTheMiner
Posts: 64
Joined: Wed Nov 19, 2014 10:30 am

Re: Write NiceHash bot, make lots of profit

Post by JoeTheMiner » Fri Oct 28, 2016 11:40 pm

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
User avatar
Chris Sokolowski
Site Admin
Posts: 945
Joined: Wed Aug 27, 2014 12:47 pm
Location: State College, PA

Re: Write NiceHash bot, make lots of profit

Post by Chris Sokolowski » Sat Oct 29, 2016 12:19 am

Thanks Joe. Let us know if there's any issues on the pool side that we can fix.
Locked