From f9be9035a81f5b05993b8f4dc9e59fa58aeafc84 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 20 Oct 2014 19:27:41 -0400 Subject: [PATCH 1/7] Fix nonce --- coinbase/CoinbaseRPC.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coinbase/CoinbaseRPC.py b/coinbase/CoinbaseRPC.py index 42b13d8..5ff8a36 100644 --- a/coinbase/CoinbaseRPC.py +++ b/coinbase/CoinbaseRPC.py @@ -51,6 +51,8 @@ def request(self, method, url, params=None): elif isinstance(self.__authentication, CoinbaseAPIKeyAuthentication): if self.__nonce is None: self.__nonce = int(time.time() * 1e6) + else: + self.__nonce += 1 message = str(self.__nonce) + url if method == 'post' or method == 'put': From 89f877303c160a073c217c67b8489d98c8335c15 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 20 Oct 2014 19:37:48 -0400 Subject: [PATCH 2/7] operations -> options (probably a typo) --- coinbase/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase/__init__.py b/coinbase/__init__.py index 17f89e9..04259ff 100644 --- a/coinbase/__init__.py +++ b/coinbase/__init__.py @@ -66,7 +66,7 @@ def create_button(self, name, price, currency, custom=None, options=None): params['custom'] = custom if options is not None: - for key, value in operation.items(): + for key, value in options.items(): params[key] = value return self.create_button_with_options(params) From 3e2edfe367b30826e2806a0fba29bca60629d661 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 22 Oct 2014 17:13:26 -0400 Subject: [PATCH 3/7] Fix close quote on enbed_html on create_button --- coinbase/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase/__init__.py b/coinbase/__init__.py index 04259ff..f912e45 100644 --- a/coinbase/__init__.py +++ b/coinbase/__init__.py @@ -82,7 +82,7 @@ def create_button_with_options(self, options=None): 'button': response['button'], 'embed_html': '
', 'success': True } From c9158de7cb6d487b15f3dfcdec4618a6f5c534d2 Mon Sep 17 00:00:00 2001 From: Matthew Bentley Date: Tue, 17 Feb 2015 16:04:21 -0500 Subject: [PATCH 4/7] Fix nonce? --- coinbase/CoinbaseRPC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase/CoinbaseRPC.py b/coinbase/CoinbaseRPC.py index 5ff8a36..29f5247 100644 --- a/coinbase/CoinbaseRPC.py +++ b/coinbase/CoinbaseRPC.py @@ -26,7 +26,7 @@ class CoinbaseRPC(object): def __init__(self, authentication, nonce=None): self.__authentication = authentication - self.__nonce = None + self.__nonce = nonce def request(self, method, url, params=None): From a832447d203286399e2ac5b6f75a6b08175610f8 Mon Sep 17 00:00:00 2001 From: Matthew Bentley Date: Wed, 18 Feb 2015 13:05:39 -0500 Subject: [PATCH 5/7] Fix expire, maybe --- coinbase/CoinbaseRPC.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/coinbase/CoinbaseRPC.py b/coinbase/CoinbaseRPC.py index 29f5247..262140e 100644 --- a/coinbase/CoinbaseRPC.py +++ b/coinbase/CoinbaseRPC.py @@ -15,6 +15,8 @@ import time import urllib.parse +from datetime import datetime, timedelta + # ----- Public Classes -------------------------------------------------------- class CoinbaseRPC(object): @@ -30,12 +32,16 @@ def __init__(self, authentication, nonce=None): def request(self, method, url, params=None): - url = self.COINBASE_API + url + now = datetime.now() + expire = now + timedelta(minutes=15) + expire_int = int(expire.timestamp()) + + url = self.COINBASE_API + url + "?expire=" + expire_int method = method.lower() if method == 'get' or method == 'delete': if params is not None: - url += '?' + urllib.parse.urlencode(params) + url += '&' + urllib.parse.urlencode(params) else: params = json.dumps(params) @@ -68,7 +74,7 @@ def request(self, method, url, params=None): headers['ACCESS_KEY'] = auth['api_key'] headers['ACCESS_SIGNATURE'] = signature - headers['ACCESS_NONCE'] = self.__nonce +# headers['ACCESS_NONCE'] = self.__nonce headers['Accept'] = 'application/json' else: raise CoinbaseAPIException('Invalid authentication mechanism') From e940b8b83fbe0ab58df437c5af5a0d87fc07c90a Mon Sep 17 00:00:00 2001 From: Matthew Bentley Date: Wed, 18 Feb 2015 13:09:30 -0500 Subject: [PATCH 6/7] Fix int->str --- coinbase/CoinbaseRPC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase/CoinbaseRPC.py b/coinbase/CoinbaseRPC.py index 262140e..6eb96be 100644 --- a/coinbase/CoinbaseRPC.py +++ b/coinbase/CoinbaseRPC.py @@ -36,7 +36,7 @@ def request(self, method, url, params=None): expire = now + timedelta(minutes=15) expire_int = int(expire.timestamp()) - url = self.COINBASE_API + url + "?expire=" + expire_int + url = self.COINBASE_API + url + "?expire=" + str(expire_int) method = method.lower() if method == 'get' or method == 'delete': From eefe0e2ea955ccfc5169234b9da947dc254a3d41 Mon Sep 17 00:00:00 2001 From: Matthew Bentley Date: Wed, 18 Feb 2015 13:11:21 -0500 Subject: [PATCH 7/7] fix --- coinbase/CoinbaseRPC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase/CoinbaseRPC.py b/coinbase/CoinbaseRPC.py index 6eb96be..98a48fe 100644 --- a/coinbase/CoinbaseRPC.py +++ b/coinbase/CoinbaseRPC.py @@ -59,7 +59,7 @@ def request(self, method, url, params=None): self.__nonce = int(time.time() * 1e6) else: self.__nonce += 1 - message = str(self.__nonce) + url + message = url if method == 'post' or method == 'put': if params is not None: