diff --git a/handler/transactions.py b/handler/transactions.py index 64fd660..1279ceb 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -76,6 +76,8 @@ class Transactions(object): self.log.info("Transaction processed: {formatted}", formatted=dumps(to_store, indent=2)) r.hmset(f"tx.{txid}", to_store) self.irc.sendmsg(f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}") + + # Partial reference implementation # Account for silly people not removing the default string # Split the reference into parts ref_split = reference.split(" ") @@ -91,6 +93,9 @@ class Transactions(object): print("Stored trade reference:", stored_trade_reference) stored_trade = False + looked_up_without_reference = False + + # Amount/currency lookup implementation if not stored_trade_reference: self.log.info(f"No reference in DB refs for {reference}", reference=reference) self.irc.sendmsg(f"No reference in DB refs for {reference}") @@ -114,6 +119,8 @@ class Transactions(object): self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX") # Close here if the amount exceeds the allowable limit for no reference return + # Note that we have looked it up without reference so we don't use +- below + looked_up_without_reference = True if not stored_trade: stored_trade = self.get_ref(stored_trade_reference.pop()) print("Stored trade:", stored_trade) @@ -132,6 +139,8 @@ class Transactions(object): # Make sure the expected amount was sent if not stored_trade["amount"] == amount: + if looked_up_without_reference: + return # 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) self.irc.sendmsg(f"Amount does not match exactly, trying with margins: min: {min_amount} / max: {max_amount}")