Add check if attribute order exists when triggering an order status

This commit is contained in:
Reckless_Satoshi 2022-01-18 14:17:41 -08:00
parent 7a6c29fe64
commit 285f85aaf2
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 4 additions and 6 deletions

View File

@ -520,7 +520,6 @@ class Logics():
# Do not gen if a taker invoice exist. Do not return if it is already locked. Return the old one if still waiting. # Do not gen if a taker invoice exist. Do not return if it is already locked. Return the old one if still waiting.
if order.taker_bond: if order.taker_bond:
# Check if status is INVGEN and still not expired
if cls.is_taker_bond_locked(order): if cls.is_taker_bond_locked(order):
return False, None return False, None
elif order.taker_bond.status == LNPayment.Status.INVGEN: elif order.taker_bond.status == LNPayment.Status.INVGEN:

View File

@ -59,7 +59,7 @@ class Command(BaseCommand):
request = LNNode.invoicesrpc.LookupInvoiceMsg(payment_hash=bytes.fromhex(hold_lnpayment.payment_hash)) request = LNNode.invoicesrpc.LookupInvoiceMsg(payment_hash=bytes.fromhex(hold_lnpayment.payment_hash))
response = stub.LookupInvoiceV2(request, metadata=[('macaroon', MACAROON.hex())]) response = stub.LookupInvoiceV2(request, metadata=[('macaroon', MACAROON.hex())])
hold_lnpayment.status = lnd_state_to_lnpayment_status[response.state] hold_lnpayment.status = lnd_state_to_lnpayment_status[response.state]
except Exception as e: except Exception as e:
# If it fails at finding the invoice it has been canceled. # If it fails at finding the invoice it has been canceled.
# On RoboSats DB we make a distinction between cancelled and returned (LND does not) # On RoboSats DB we make a distinction between cancelled and returned (LND does not)
@ -105,21 +105,20 @@ class Command(BaseCommand):
# If the LNPayment goes to LOCKED (ACCEPTED) # If the LNPayment goes to LOCKED (ACCEPTED)
if lnpayment.status == LNPayment.Status.LOCKED: if lnpayment.status == LNPayment.Status.LOCKED:
try: try:
# It is a maker bond => Publish order. # It is a maker bond => Publish order.
if not lnpayment.order_made == None: if hasattr(lnpayment, 'order_made' ):
Logics.publish_order(lnpayment.order_made) Logics.publish_order(lnpayment.order_made)
return return
# It is a taker bond => close contract. # It is a taker bond => close contract.
elif not lnpayment.order_taken == None: elif hasattr(lnpayment, 'order_taken' ):
if lnpayment.order_taken.status == Order.Status.TAK: if lnpayment.order_taken.status == Order.Status.TAK:
Logics.finalize_contract(lnpayment.order_taken) Logics.finalize_contract(lnpayment.order_taken)
return return
# It is a trade escrow => move foward order status. # It is a trade escrow => move foward order status.
elif not lnpayment.order_escrow == None: elif hasattr(lnpayment, 'order_escrow' ):
Logics.trade_escrow_received(lnpayment.order_escrow) Logics.trade_escrow_received(lnpayment.order_escrow)
return return
except Exception as e: except Exception as e: