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.msg(
|
||||||
self.irc.client.channel, f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}"
|
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:
|
if not stored_trade["currency"] == currency:
|
||||||
self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}")
|
self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}")
|
||||||
return
|
return
|
||||||
if not stored_trade["amount"] == amount:
|
if not stored_trade["amount"] == amount:
|
||||||
self.irc.client.msg(self.irc.client.channel, f"Amount mismatch, Agora: {stored_trade['amount']} / Revolut: {amount}")
|
self.irc.client.msg(self.irc.client.channel, f"Amount mismatch, Agora: {stored_trade['amount']} / Revolut: {amount}")
|
||||||
return
|
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}")
|
self.irc.client.msg(self.irc.client.channel, f"Account type is not Revolut: {account_type}")
|
||||||
return
|
return
|
||||||
self.irc.client.msg(self.irc.client.channel, f"All checks passed, would release funds for {stored_trade['id']}")
|
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):
|
def new_trade(self, trade_id, buyer, currency, amount, amount_xmr):
|
||||||
reference = "".join(choices(ascii_uppercase, k=5))
|
reference = "".join(choices(ascii_uppercase, k=5))
|
||||||
reference = f"XMR-{reference}"
|
reference = f"XMR-{reference}"
|
||||||
print("NEW TRADE")
|
|
||||||
existing_ref = r.get(f"trade.{trade_id}.reference")
|
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)
|
r.set(f"trade.{trade_id}.reference", reference)
|
||||||
to_store = {
|
to_store = {
|
||||||
"id": trade_id,
|
"id": trade_id,
|
||||||
|
@ -115,11 +122,10 @@ class Transactions(object):
|
||||||
"amount_xmr": amount_xmr,
|
"amount_xmr": amount_xmr,
|
||||||
"reference": reference,
|
"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)
|
r.hmset(f"trade.{reference}", to_store)
|
||||||
self.irc.client.msg(self.irc.client.channel, f"Would send reference to {trade_id}: {reference}")
|
self.irc.client.msg(self.irc.client.channel, f"Generated reference for {trade_id}: {reference}")
|
||||||
else:
|
self.agora.agora.contact_message_post(trade_id, f"Hi! When sending the payment please user reference code: {reference}")
|
||||||
self.irc.client.msg(self.irc.client.channel, f"Using existing reference for stored trade {trade_id}: {existing_ref}")
|
|
||||||
|
|
||||||
def find_tx(self, reference, amount):
|
def find_tx(self, reference, amount):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue