From 08636c32eeeef8ce8aa6718ffaab4179b78d899b Mon Sep 17 00:00:00 2001 From: Oliver Mattos Date: Sat, 16 Jan 2021 14:16:08 +0000 Subject: [PATCH 1/3] Update example to use a currency pair that exists --- clientExample.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clientExample.py b/clientExample.py index d5c6557..cc92133 100755 --- a/clientExample.py +++ b/clientExample.py @@ -46,12 +46,12 @@ def print_out(ws, msg): coinfloor.WatchOrders( base = Assets["XBT"], - counter = Assets["USD"], + counter = Assets["GBP"], watch = True ) coinfloor.WatchTicker( base = Assets["XBT"], - counter = Assets["USD"], + counter = Assets["GBP"], watch = True ) From 0774d6907f3d3aab210bd49c38f32030ebd11281 Mon Sep 17 00:00:00 2001 From: Oliver Mattos Date: Sat, 16 Jan 2021 14:16:37 +0000 Subject: [PATCH 2/3] Update client for changed websocket API --- coinfloor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coinfloor.py b/coinfloor.py index db14c90..df30038 100755 --- a/coinfloor.py +++ b/coinfloor.py @@ -112,7 +112,7 @@ def __init__(self, url, ) - def _open_handler(self, ws): + def _open_handler(self): self.conditional.acquire() self.connected = True self.conditional.notifyAll() @@ -122,14 +122,14 @@ def _open_handler(self, ws): self.open_handler(self) - def _err_handler(self, ws, error): + def _err_handler(self, error): if self.err_handler is not None: self.err_handler(self, error) else: raise ConnectionError("Connection to %s failed: %s"%(self.url, error)) - def _msg_handler(self, ws, message): + def _msg_handler(self, message): if not self.auth_complete: body = json.loads(message) self._body_scan(body) From b3bc4cc8cb5cdfba028e1394e994680e3df38081 Mon Sep 17 00:00:00 2001 From: Oliver Mattos Date: Thu, 25 Feb 2021 10:38:32 +0000 Subject: [PATCH 3/3] Fix all error handling codepaths --- coinfloor.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/coinfloor.py b/coinfloor.py index df30038..05259e0 100755 --- a/coinfloor.py +++ b/coinfloor.py @@ -140,15 +140,15 @@ def _msg_handler(self, message): def _process_welcome_message(self, body): if "nonce" not in body: - self._err_handler(self, "Invalid 'Welcome' message received") + self._err_handler("Invalid 'Welcome' message received") elif self.server_nonce is not None: - self._err_handler(self, "Server nonce received more than once") + self._err_handler("Server nonce received more than once") else: try: self.conditional.acquire() self.server_nonce = base64.b64decode(body["nonce"]) except TypeError: - self._err_handler(self, "Server nonce received is invalid") + self._err_handler("Server nonce received is invalid") finally: self.conditional.notify_all() self.conditional.release() @@ -229,7 +229,7 @@ def _smart_connect(self): lambda: self.connected ) except KeyboardInterrupt: - self._err_handler(self, "Interrupted while establishing the connection") + self._err_handler("Interrupted while establishing the connection") def _wait_for_server_nonce(self): @@ -238,7 +238,7 @@ def _wait_for_server_nonce(self): lambda: self.server_nonce is not None ) except KeyboardInterrupt: - self._err_handler(self, "Interrupted while waiting for server nonce") + self._err_handler("Interrupted while waiting for server nonce") def _wait_for_auth_response(self): @@ -247,7 +247,7 @@ def _wait_for_auth_response(self): lambda: self.auth_complete is True ) except KeyboardInterrupt: - self._err_handler(self, "Interrupted while waiting for authentication to complete") + self._err_handler("Interrupted while waiting for authentication to complete") def _compute_ecdsa_signature(self): @@ -278,7 +278,7 @@ def _compute_ecdsa_signature(self): return r, s except ValueError: - self._err_handler(self, "Invalid signature data") + self._err_handler("Invalid signature data") def _send_signature(self, **sig_data): @@ -290,14 +290,14 @@ def authenticate(self): return if self.user_id is None or self.cookie is None or self.passphrase is None: - self._err_handler(self, "Missing authentication data") + self._err_handler("Missing authentication data") return self._smart_connect() self._wait_for_server_nonce() if self.server_nonce is None: - self._err_handler(self, "Server nonce not received before timeout") + self._err_handler("Server nonce not received before timeout") else: signature = self._compute_ecdsa_signature() @@ -313,9 +313,9 @@ def authenticate(self): self._wait_for_auth_response() if not self.auth_complete: - self._err_handler(self, "Unable to complete authentication") + self._err_handler("Unable to complete authentication") elif not self.auth_okay: - self._err_handler(self, "Authentication failed") + self._err_handler("Authentication failed") def GetBalances(self, **data):