From 4053dce0484636d1060e3b0e95211128d5e88c1e Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 1 Jan 2022 20:22:53 +0000 Subject: [PATCH] Fix alt reference implementation --- handler/transactions.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/handler/transactions.py b/handler/transactions.py index 0be9144..d1e0f00 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -83,14 +83,12 @@ class Transactions(object): ref_split = reference.split(" ") # Get all existing references existing_refs = self.get_refs() - print("Existing references:", existing_refs) # Get all parts of the given reference split that match the existing references stored_trade_reference = set(existing_refs).intersection(set(ref_split)) if len(stored_trade_reference) > 1: self.log.error("Multiple references valid for TXID {txid}: {reference}", txid=txid, reference=reference) self.irc.sendmsg(f"Multiple references valid for TXID {txid}: {reference}") return - print("Stored trade reference:", stored_trade_reference) stored_trade = False looked_up_without_reference = False @@ -117,10 +115,10 @@ class Transactions(object): if currency == "USD": amount_usd = amount else: - rates = self.get_rates_all() + rates = self.agora.get_rates_all() amount_usd = amount / rates[currency] # Amount is reliable here as it is checked by find_trade, so no need for stored_trade["amount"] - if amount_usd > settings.Agora.AcceptableAltLookupUSD: + if float(amount_usd) > float(settings.Agora.AcceptableAltLookupUSD): self.log.info("Not checking against amount and currency as amount exceeds MAX") 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 @@ -130,7 +128,6 @@ class Transactions(object): looked_up_without_reference = True if not stored_trade: stored_trade = self.get_ref(stored_trade_reference.pop()) - print("Stored trade:", stored_trade) if not stored_trade: self.log.info(f"No reference in DB for {reference}", reference=reference) self.irc.sendmsg(f"No reference in DB for {reference}") @@ -158,11 +155,10 @@ class Transactions(object): if not account_type == "revolut": self.irc.sendmsg(f"Account type is not Revolut: {account_type}") return - # self.irc.sendmsg(f"All checks passed, releasing funds for {stored_trade['id']} / {reference}") + self.irc.sendmsg(f"All checks passed, releasing funds for {stored_trade['id']} / {reference}") # rtrn = self.agora.release_funds(stored_trade["id"]) # self.agora.agora.contact_message_post(stored_trade["id"], "Thanks! Releasing now :)") # self.irc.sendmsg(dumps(rtrn)) - self.irc.sendmsg(f"DRY RUN releasing funds for {stored_trade['id']} / {reference}") def new_trade(self, trade_id, buyer, currency, amount, amount_xmr): """ @@ -229,7 +225,7 @@ class Transactions(object): matching_refs = [] for ref in refs: stored_trade = self.get_ref(ref) - if stored_trade["currency"] == currency and stored_trade["amount"] == amount: + if stored_trade["currency"] == currency and float(stored_trade["amount"]) == float(amount): matching_refs.append(stored_trade) if len(matching_refs) != 1: self.log.error("Find trade returned multiple results for TXID {txid}: {matching_refs}", txid=txid, matching_refs=matching_refs)