Skip to content

Commit

Permalink
Fixed bug in offline payment related to PIN parsing and LNbits Paymen…
Browse files Browse the repository at this point in the history
…tState introduction
  • Loading branch information
pieterjm committed Oct 16, 2024
1 parent 32946cf commit a5ffba0
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 15 deletions.
Binary file modified static/firmware/ESP32_3248S035C/firmware.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_BEER.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_BITCOINTAPS.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_BONANZA.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_NONE.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_TEST.bin
Binary file not shown.
Binary file modified static/firmware/ESP32_3248S035C/firmware_VJZGBT.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion static/firmware/ESP32_3248S035C/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BitcoinTaps PartyTap",
"version": "863500",
"version": "865875",
"new_install_prompt_erase": true,
"builds": [
{
Expand Down
7 changes: 4 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ async def task_create_offline_payment(request: Request, device_id: str, encrypte
status_code=HTTPStatus.NOT_FOUND, detail="switch does not exist"
)

# extract PIN
decrypted_pin_part = decrypted_message[9:16].decode()
# extract PIN
# e = 'b'Lfzmmibg:961:\x00\xfe?!\xf9\xabl
decrypted_pin_part = decrypted_message[9:13].decode()
result = decrypted_pin_part.find(':')
if result == -1:
raise HTTPException(
Expand Down Expand Up @@ -221,7 +222,7 @@ async def task_send_switches(device_id: str):
"event":"switches",
"switches": [],
"key": device.key,
"version": "863500",
"version": "865875",
"branding": device.branding
}
except Exception as err:
Expand Down
2 changes: 1 addition & 1 deletion templates/partytap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ <h6 class="text-subtitle1 q-my-none">
data: function () {
return {
tab: 'mails',
version: '863500',
version: '865875',
hostname: window.location.host,
protocol: window.location.protocol,
location: window.location.hostname,
Expand Down
24 changes: 14 additions & 10 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse

from lnbits.core.crud import update_payment_status
from lnbits.core.models import User
from lnbits.core.crud import get_standalone_payment
from lnbits.core.models import User, PaymentState
from lnbits.core.views.api import api_payment
from lnbits.decorators import check_user_exists

Expand All @@ -27,20 +27,24 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
"/{paymentid}", name="partytap.displaypin", response_class=HTMLResponse
)
async def displaypin(request: Request, paymentid: str):
payment = await get_payment(paymentid)
if not payment:
partytap_payment = await get_payment(paymentid)
if not partytap_payment:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="No payment"
)
status = await api_payment(payment.payhash)
if status["paid"]:
await update_payment_status(
checking_id=payment.payhash, pending=True

payment = await get_standalone_payment(partytap_payment.payhash)
if not payment:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Payment not found."
)
status = await payment.check_status()
if status.success:
return partytap_renderer().TemplateResponse(
"partytap/paid.html", {"request": request, "pin": payment.pin}
"partytap/paid.html", {"request": request, "pin": partytap_payment.pin}
)
return partytap_renderer().TemplateResponse(
"partytap/error.html",
{"request": request, "pin": "filler", "not_paid": True},
)
)

0 comments on commit a5ffba0

Please sign in to comment.