Add debugging in release

This commit is contained in:
Mark Veidemanis 2022-04-23 11:53:41 +01:00
parent 3ef24e86c8
commit 75062514c9
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 17 additions and 1 deletions

View File

@ -243,6 +243,8 @@ class Transactions(util.Base):
senders = util.convert(senders) senders = util.convert(senders)
return senders return senders
# def get_name_derivations(self, )
def check_valid_sender(self, reference, platform, bank_sender, platform_buyer): def check_valid_sender(self, reference, platform, bank_sender, platform_buyer):
""" """
Check that either: Check that either:
@ -381,9 +383,14 @@ class Transactions(util.Base):
# Check sender - we don't do anything with this yet # Check sender - we don't do anything with this yet
sender_valid = self.check_valid_sender(reference, platform, sender, platform_buyer) sender_valid = self.check_valid_sender(reference, platform, sender, platform_buyer)
print("Sender valid for trade: ", sender_valid) print("Sender valid for trade: ", sender_valid)
# trade_released = self.release_map_trade(reference, txid)
# if trade_released:
# self.ux.notify.notify_complete_trade(amount, currency)
# else:
# self.log.error(f"Cannot release trade {reference}.")
# return
self.release_funds(stored_trade["id"], stored_trade["reference"]) self.release_funds(stored_trade["id"], stored_trade["reference"])
self.ux.notify.notify_complete_trade(amount, currency)
def release_funds(self, trade_id, reference): def release_funds(self, trade_id, reference):
stored_trade = self.get_ref(reference) stored_trade = self.get_ref(reference)
@ -418,17 +425,23 @@ class Transactions(util.Base):
Map a trade to a transaction and release if no other TX is Map a trade to a transaction and release if no other TX is
mapped to the same trade. mapped to the same trade.
""" """
print("Release map trade called", reference, tx)
stored_trade = self.get_ref(reference) stored_trade = self.get_ref(reference)
print("Stored trade", stored_trade)
if not stored_trade: if not stored_trade:
self.log.error(f"Could not get stored trade for {reference}.")
return None return None
tx_obj = self.get_tx(tx) tx_obj = self.get_tx(tx)
print("tx_obj", tx_obj)
if not tx_obj: if not tx_obj:
self.log.error(f"Could not get TX for {tx}.")
return None return None
platform = stored_trade["subclass"] platform = stored_trade["subclass"]
platform_buyer = stored_trade["buyer"] platform_buyer = stored_trade["buyer"]
bank_sender = tx_obj["sender"] bank_sender = tx_obj["sender"]
trade_id = stored_trade["id"] trade_id = stored_trade["id"]
is_updated = self.update_trade_tx(reference, tx) is_updated = self.update_trade_tx(reference, tx)
print("is_updated", is_updated)
if is_updated is None: if is_updated is None:
return None return None
elif is_updated is True: elif is_updated is True:
@ -437,6 +450,9 @@ class Transactions(util.Base):
print("Adding mapped bank sender", platform_buyer, bank_sender) print("Adding mapped bank sender", platform_buyer, bank_sender)
self.add_bank_sender(platform, platform_buyer, bank_sender) self.add_bank_sender(platform, platform_buyer, bank_sender)
return True return True
elif is_updated is False:
# Already mapped
self.log.error(f"Trade {reference} already has a TX mapped, cannot map {tx}.")
return False return False
def find_trades_by_uid(self, uid): def find_trades_by_uid(self, uid):