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