Don't check non-exact values if we looked up without reference

This commit is contained in:
Mark Veidemanis 2022-01-01 19:33:15 +00:00
parent 19724eac77
commit 5ea1c26a84
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 9 additions and 0 deletions

View File

@ -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}")