Fix incoming transaction matching
This commit is contained in:
parent
f0b31ac17d
commit
cd6e19a38a
|
@ -88,14 +88,20 @@ class Transactions(object):
|
|||
self.irc.client.msg(
|
||||
self.irc.client.channel, f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}"
|
||||
)
|
||||
stored_trade = r.hmget(f"trade.{reference}")
|
||||
stored_trade = r.hgetall(f"trade.{reference}")
|
||||
if not stored_trade:
|
||||
self.log.info(f"No reference in DB for {reference}")
|
||||
return
|
||||
stored_trade = convert(stored_trade)
|
||||
amount = float(amount)
|
||||
stored_trade["amount"] = float(stored_trade["amount"])
|
||||
if not stored_trade["currency"] == currency:
|
||||
self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}")
|
||||
return
|
||||
if not stored_trade["amount"] == amount:
|
||||
self.irc.client.msg(self.irc.client.channel, f"Amount mismatch, Agora: {stored_trade['amount']} / Revolut: {amount}")
|
||||
return
|
||||
if not account_type == "Revolut":
|
||||
if not account_type == "revolut":
|
||||
self.irc.client.msg(self.irc.client.channel, f"Account type is not Revolut: {account_type}")
|
||||
return
|
||||
self.irc.client.msg(self.irc.client.channel, f"All checks passed, would release funds for {stored_trade['id']}")
|
||||
|
@ -103,9 +109,10 @@ class Transactions(object):
|
|||
def new_trade(self, trade_id, buyer, currency, amount, amount_xmr):
|
||||
reference = "".join(choices(ascii_uppercase, k=5))
|
||||
reference = f"XMR-{reference}"
|
||||
print("NEW TRADE")
|
||||
existing_ref = r.get(f"trade.{trade_id}.reference")
|
||||
if not existing_ref:
|
||||
if existing_ref:
|
||||
self.irc.client.msg(self.irc.client.channel, f"Existing reference for {trade_id}: {existing_ref.decode('utf-8')}")
|
||||
else:
|
||||
r.set(f"trade.{trade_id}.reference", reference)
|
||||
to_store = {
|
||||
"id": trade_id,
|
||||
|
@ -115,11 +122,10 @@ class Transactions(object):
|
|||
"amount_xmr": amount_xmr,
|
||||
"reference": reference,
|
||||
}
|
||||
self.log.info(f"Storing trade information: {to_store}")
|
||||
self.log.info(f"Storing trade information: {str(to_store)}")
|
||||
r.hmset(f"trade.{reference}", to_store)
|
||||
self.irc.client.msg(self.irc.client.channel, f"Would send reference to {trade_id}: {reference}")
|
||||
else:
|
||||
self.irc.client.msg(self.irc.client.channel, f"Using existing reference for stored trade {trade_id}: {existing_ref}")
|
||||
self.irc.client.msg(self.irc.client.channel, f"Generated reference for {trade_id}: {reference}")
|
||||
self.agora.agora.contact_message_post(trade_id, f"Hi! When sending the payment please user reference code: {reference}")
|
||||
|
||||
def find_tx(self, reference, amount):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue