Skip to content

Commit

Permalink
lnaddress working, removed invoice choice
Browse files Browse the repository at this point in the history
  • Loading branch information
arcbtc committed Aug 16, 2024
1 parent d19e619 commit f9e0d2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ async def register_atm_payment(device, p):
lnurldevicepayment = await get_recent_lnurldevicepayment(p)
# If the payment is already registered and been paid, return None
if lnurldevicepayment and lnurldevicepayment.payload == lnurldevicepayment.payhash:
return None
return None, None
# If the payment is already registered and not been paid, return lnurlpayment record
elif lnurldevicepayment and lnurldevicepayment.payload != lnurldevicepayment.payhash:
return lnurldevicepayment
return lnurldevicepayment, None
# else create a new lnurlpayment record
else:
data = base64.urlsafe_b64decode(p)
Expand Down
5 changes: 3 additions & 2 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ async def get_lnurldevice_payment_lightning(
# If its an lnaddress or lnurlp get the request from callback
elif ln[:5] == "lnurl" or "@" in ln and "." in ln.split("@")[-1]:
data = await api_lnurlscan(ln)
logger.debug(data)
if data.get("status") == "ERROR":
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST, detail=data.get("reason")
Expand All @@ -190,7 +191,7 @@ async def get_lnurldevice_payment_lightning(
else:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Wrong format for payment, could not be made. Use invoice, LNaddress or LNURLp",
detail="Wrong format for payment, could not be made. Use LNaddress or LNURLp",
)

# Finally log the payment and make the payment
Expand All @@ -204,7 +205,7 @@ async def get_lnurldevice_payment_lightning(
payment = await pay_invoice(
wallet_id=lnurldevice.wallet,
payment_request=ln,
max_sat=price_msat / 1000,
max_sat=price_msat,
extra={"tag": "lnurldevice", "id": lnurldevicepayment.id},
)
assert payment
Expand Down

0 comments on commit f9e0d2c

Please sign in to comment.