diff --git a/api/logics.py b/api/logics.py index 4be9217e..384922fa 100644 --- a/api/logics.py +++ b/api/logics.py @@ -234,7 +234,10 @@ class Logics: if maker_is_seller: cls.settle_bond(order.maker_bond) cls.return_bond(order.taker_bond) - cls.cancel_escrow(order) + try: # If seller is offline the escrow LNpayment does not even exist + cls.cancel_escrow(order) + except: + pass order.status = Order.Status.EXP order.save() return True @@ -242,7 +245,10 @@ class Logics: # If maker is buyer, settle the taker's bond order goes back to public else: cls.settle_bond(order.taker_bond) - cls.cancel_escrow(order) + try: # If seller is offline the escrow LNpayment does not even exist + cls.cancel_escrow(order) + except: + pass order.taker = None order.taker_bond = None order.trade_escrow = None diff --git a/api/management/commands/clean_orders.py b/api/management/commands/clean_orders.py index 8c19067c..a8d93d65 100644 --- a/api/management/commands/clean_orders.py +++ b/api/management/commands/clean_orders.py @@ -43,6 +43,8 @@ class Command(BaseCommand): debug = {} debug["num_expired_orders"] = len(queryset) debug["expired_orders"] = [] + debug["failed_order_expiry"] = [] + debug["reason_failure"] = [] for idx, order in enumerate(queryset): context = str(order) + " was " + Order.Status( @@ -55,6 +57,9 @@ class Command(BaseCommand): # It should not happen, but if it cannot locate the hold invoice # it probably was cancelled by another thread, make it expire anyway. except Exception as e: + debug["failed_order_expiry"].append({idx: context}) + debug["reason_failure"].append({idx: str(e)}) + if "unable to locate invoice" in str(e): self.stdout.write(str(e)) order.status = Order.Status.EXP