Skip to content

Commit

Permalink
Fix new invoice routing budget not accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed May 2, 2024
1 parent e8283f2 commit f38f48a
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,31 +909,21 @@ def update_invoice(cls, order, user, invoice, routing_budget_ppm):
if not payout["valid"]:
return False, payout["context"]

if order.payout:
order.payout.invoice = invoice
order.payout.status = LNPayment.Status.VALIDI
order.payout.num_satoshis = num_satoshis
order.payout.description = payout["description"]
order.payout.payment_hash = payout["payment_hash"]
order.payout.created_at = payout["created_at"]
order.payout.expires_at = payout["expires_at"]
order.payout.save()
else:
order.payout = LNPayment.objects.create(
concept=LNPayment.Concepts.PAYBUYER,
type=LNPayment.Types.NORM,
sender=User.objects.get(username=ESCROW_USERNAME),
receiver=user,
routing_budget_ppm=routing_budget_ppm,
routing_budget_sats=routing_budget_sats,
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.payout = LNPayment.objects.update_or_create(
concept=LNPayment.Concepts.PAYBUYER,
type=LNPayment.Types.NORM,
sender=User.objects.get(username=ESCROW_USERNAME),
receiver=user,
routing_budget_ppm=routing_budget_ppm,
routing_budget_sats=routing_budget_sats,
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
order.save(update_fields=["payout", "is_swap"])
Expand Down

0 comments on commit f38f48a

Please sign in to comment.