Fix order status change must happen exactly when last sats update on contract finalization

This commit is contained in:
Reckless_Satoshi 2023-09-11 08:23:11 -07:00
parent 1600b58bab
commit c7a14fbc56
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 16 additions and 4 deletions

View File

@ -1310,22 +1310,24 @@ class Logics:
# (This is the last update to "last_satoshis", it becomes the escrow amount next)
order.last_satoshis = cls.satoshis_now(order)
order.last_satoshis_time = timezone.now()
order.taker_bond.status = LNPayment.Status.LOCKED
order.taker_bond.save(update_fields=["status"])
# With the bond confirmation the order is extended 'public_order_duration' hours
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.WF2)
)
order.update_status(Order.Status.WF2)
order.status = Order.Status.WF2
order.save(
update_fields=[
"status",
"last_satoshis",
"last_satoshis_time",
"expires_at",
]
)
order.taker_bond.status = LNPayment.Status.LOCKED
order.taker_bond.save(update_fields=["status"])
# Both users robots are added one more contract // Unsafe can add more than once.
order.maker.robot.total_contracts += 1
order.taker.robot.total_contracts += 1

View File

@ -307,7 +307,17 @@ class OrderView(viewsets.ViewSet):
data["escrow_locked"] = False
# If both bonds are locked, participants can see the final trade amount in sats.
if order.taker_bond:
if order.status in [
Order.Status.WF2,
Order.Status.WFI,
Order.Status.WFE,
Order.Status.CCA,
Order.Status.FSE,
Order.Status.DIS,
Order.Status.PAY,
Order.Status.SUC,
Order.Status.FAI,
]:
if (
order.maker_bond.status
== order.taker_bond.status