From 75062514c9da15f52102be5fa85e1dd6ec9bbe8c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 23 Apr 2022 11:53:41 +0100 Subject: [PATCH] Add debugging in release --- handler/transactions.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/handler/transactions.py b/handler/transactions.py index c74b748..f824864 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -243,6 +243,8 @@ class Transactions(util.Base): senders = util.convert(senders) return senders + # def get_name_derivations(self, ) + def check_valid_sender(self, reference, platform, bank_sender, platform_buyer): """ Check that either: @@ -381,9 +383,14 @@ class Transactions(util.Base): # Check sender - we don't do anything with this yet sender_valid = self.check_valid_sender(reference, platform, sender, platform_buyer) 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.ux.notify.notify_complete_trade(amount, currency) def release_funds(self, trade_id, 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 mapped to the same trade. """ + print("Release map trade called", reference, tx) stored_trade = self.get_ref(reference) + print("Stored trade", stored_trade) if not stored_trade: + self.log.error(f"Could not get stored trade for {reference}.") return None tx_obj = self.get_tx(tx) + print("tx_obj", tx_obj) if not tx_obj: + self.log.error(f"Could not get TX for {tx}.") return None platform = stored_trade["subclass"] platform_buyer = stored_trade["buyer"] bank_sender = tx_obj["sender"] trade_id = stored_trade["id"] is_updated = self.update_trade_tx(reference, tx) + print("is_updated", is_updated) if is_updated is None: return None elif is_updated is True: @@ -437,6 +450,9 @@ class Transactions(util.Base): print("Adding mapped bank sender", platform_buyer, bank_sender) self.add_bank_sender(platform, platform_buyer, bank_sender) 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 def find_trades_by_uid(self, uid):