From 6418c5ecca1815b8abebd2b1600bb2deb68e9e51 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 29 Dec 2021 15:32:38 +0000 Subject: [PATCH] Add some comments to Transactions --- handler/transactions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/handler/transactions.py b/handler/transactions.py index 900347b..f6e378a 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -78,10 +78,12 @@ class Transactions(object): self.irc.client.msg( self.irc.client.channel, f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}" ) + # Try getting the trade by the reference ID given stored_trade = self.get_ref(reference) if not stored_trade: self.log.info(f"No reference in DB for {reference}") self.irc.client.msg(self.irc.client.channel, f"No reference in DB for {reference}") + # Try getting the trade by the reference, using it as a TXID ref2 = self.tx_to_ref(reference) if not ref2: self.log.info("No TXID in DB for {reference}") @@ -92,9 +94,13 @@ class Transactions(object): amount = float(amount) stored_trade["amount"] = float(stored_trade["amount"]) + + # Make sure it was sent in the expected currency if not stored_trade["currency"] == currency: self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}") return + + # Make sure the expected amount was sent if not stored_trade["amount"] == amount: # If the amount does not match exactly, get the min and max values for our given acceptable margins for trades min_amount, max_amount = self.agora.get_acceptable_margins(currency, amount) @@ -107,6 +113,7 @@ class Transactions(object): f"Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}", ) return + # Make sure the account type was Revolut, as these are completed instantly if not account_type == "revolut": self.irc.client.msg(self.irc.client.channel, f"Account type is not Revolut: {account_type}") return