diff --git a/api/logics.py b/api/logics.py index 3fb06b2b..7049e21c 100644 --- a/api/logics.py +++ b/api/logics.py @@ -893,7 +893,7 @@ class Logics: if order.status == Order.Status.FAI: if order.payout.status != LNPayment.Status.EXPIRE: return False, { - "bad_request": "You can only submit an invoice after expiration or 3 failed attempts" + "bad_invoice": "You can only submit an invoice after expiration or 3 failed attempts" } # cancel onchain_payout if existing @@ -909,25 +909,24 @@ class Logics: if not payout["valid"]: return False, payout["context"] - order.payout, _ = LNPayment.objects.update_or_create( + if order.payout: + if order.payout.payment_hash == payout["payment_hash"]: + return False, {"bad_invoice": "You must submit a NEW invoice"} + + order.payout = LNPayment.objects.create( concept=LNPayment.Concepts.PAYBUYER, type=LNPayment.Types.NORM, sender=User.objects.get(username=ESCROW_USERNAME), - # In case this user has other payouts, update the one related to this order. - order_paid_LN=order, receiver=user, routing_budget_ppm=routing_budget_ppm, routing_budget_sats=routing_budget_sats, - # if there is a LNPayment matching these above, it updates that one with defaults below. - defaults={ - "invoice": invoice, - "status": LNPayment.Status.VALIDI, - "num_satoshis": num_satoshis, - "description": payout["description"], - "payment_hash": payout["payment_hash"], - "created_at": payout["created_at"], - "expires_at": payout["expires_at"], - }, + invoice=invoice, + status=LNPayment.Status.VALIDI, + num_satoshis=num_satoshis, + description=payout["description"], + payment_hash=payout["payment_hash"], + created_at=payout["created_at"], + expires_at=payout["expires_at"], ) order.is_swap = False diff --git a/requirements.txt b/requirements.txt index 54b51f92..fb83f7a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django==4.2.11 +django==5.0.4 django-admin-relation-links==0.2.5 django-celery-beat==2.6.0 django-celery-results==2.5.1 @@ -16,7 +16,7 @@ Pillow==10.1.0 python-decouple==3.8 requests==2.31.0 ring==0.10.1 -git+https://github.com/RoboSats/Robohash.git +git+https://github.com/RoboSats/Robohash.git@master gunicorn==22.0.0 psycopg2==2.9.9 SQLAlchemy==2.0.16 diff --git a/requirements_dev.txt b/requirements_dev.txt index c04f2f5f..39535d27 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,4 @@ coverage==7.5.0 ruff==0.4.2 -drf-openapi-tester @ git+https://github.com/Reckless-Satoshi/drf-openapi-tester.git@soften-django-requirements +git+https://github.com/Reckless-Satoshi/drf-openapi-tester.git@soften-django-requirements pre-commit==3.7.0 \ No newline at end of file