Skip to content

Commit

Permalink
Fix for INVALID_SIGNATURE in python3.x.x (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso authored and ericsomdahl committed Dec 12, 2018
1 parent 69984c4 commit 2dbc08e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bittrex/bittrex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import time
import hmac
import hashlib

import sys
try:
from urllib import urlencode
except ImportError:
Expand Down Expand Up @@ -147,9 +147,17 @@ def _api_query(self, protection=None, path_dict=None, options=None):
request_url += urlencode(options)

try:
apisign = hmac.new(self.api_secret.encode(),
request_url.encode(),
hashlib.sha512).hexdigest()
if sys.version_info >= (3, 0) and protection != PROTECTION_PUB:

apisign = hmac.new(bytearray(self.api_secret, 'ascii'),
bytearray(request_url, 'ascii'),
hashlib.sha512).hexdigest()

else:

apisign = hmac.new(self.api_secret.encode(),
request_url.encode(),
hashlib.sha512).hexdigest()

self.wait()

Expand Down

0 comments on commit 2dbc08e

Please sign in to comment.