From a5ffba05711df955210c8937d47883cee87bca5f Mon Sep 17 00:00:00 2001 From: pieterjm Date: Wed, 16 Oct 2024 10:40:39 +0200 Subject: [PATCH] Fixed bug in offline payment related to PIN parsing and LNbits PaymentState introduction --- static/firmware/ESP32_3248S035C/firmware.bin | Bin 1504688 -> 1504688 bytes .../ESP32_3248S035C/firmware_BEER.bin | Bin 1570304 -> 1570304 bytes .../ESP32_3248S035C/firmware_BITCOINTAPS.bin | Bin 1504688 -> 1504688 bytes .../ESP32_3248S035C/firmware_BONANZA.bin | Bin 1504800 -> 1504800 bytes .../ESP32_3248S035C/firmware_NONE.bin | Bin 1380704 -> 1380704 bytes .../ESP32_3248S035C/firmware_TEST.bin | Bin 1577472 -> 1577472 bytes .../ESP32_3248S035C/firmware_VJZGBT.bin | Bin 1500688 -> 1500688 bytes static/firmware/ESP32_3248S035C/manifest.json | 2 +- tasks.py | 7 ++--- templates/partytap/index.html | 2 +- views.py | 24 ++++++++++-------- 11 files changed, 20 insertions(+), 15 deletions(-) diff --git a/static/firmware/ESP32_3248S035C/firmware.bin b/static/firmware/ESP32_3248S035C/firmware.bin index 4fde8a81c42adcc0c92db162826aa433f0570b44..aa5674725ca718e49254a9086517b767d91b5d78 100644 GIT binary patch delta 183 zcmdn+I(ozF=m{GXUX{l#oN`OY#%aQO^Ni=WG(=qw&QqQ5V|RDf{3q=0*|Vm9lwu0l ztiTw@&SGj|Zra?$(cZ+t2*gZ4%nZaVK+FonY(UHo#2|T2Am##MZXo6XVqPHT17dz4 z764*FAQl2*VIUR(V$tnQ9Adn074^eg0z2N=-8SAf`_n@`Z@pbRx@{M`+*Ng2xSLTs I<;gc801R?N*8l(j delta 183 zcmdn+I(ozF=m{GXaxMOSpF diff --git a/static/firmware/ESP32_3248S035C/firmware_BEER.bin b/static/firmware/ESP32_3248S035C/firmware_BEER.bin index 07f5c16dca583dbc004ce4637895c021f00cf603..7c99687b81ffb0d4a5f5a9f7cbaef89a7b299fa5 100644 GIT binary patch delta 186 zcmZp86W{PAe!>QYL$kj=w3wuIxoED$#b&nKiPtC2n4a;rFA(zqF+UIs z0I?tt3jwh(5Q_k@C=iQnZ{iS-eXE#dG5uwuW^7}o-nWgVQBGxo^+uOHG}9+ubGp;N J`{9g|O?`-8dHUr!OdamQ87rfGFT=bN(=j02}l`93vko|5{iyw8&-Dg|s- zV2opDF*Y?YXl~+YZ{lDCVkRJF24WTrFA(zqF+UIs z0I?tt3jwh(5Q_k@C=iQnZ{iS-eXH0yRV(;N$h-zA?fBo^&LMMotM_T#7e2H|;r7OT J+zD*1Cjd~QL{I<# diff --git a/static/firmware/ESP32_3248S035C/firmware_BITCOINTAPS.bin b/static/firmware/ESP32_3248S035C/firmware_BITCOINTAPS.bin index 4fde8a81c42adcc0c92db162826aa433f0570b44..aa5674725ca718e49254a9086517b767d91b5d78 100644 GIT binary patch delta 183 zcmdn+I(ozF=m{GXUX{l#oN`OY#%aQO^Ni=WG(=qw&QqQ5V|RDf{3q=0*|Vm9lwu0l ztiTw@&SGj|Zra?$(cZ+t2*gZ4%nZaVK+FonY(UHo#2|T2Am##MZXo6XVqPHT17dz4 z764*FAQl2*VIUR(V$tnQ9Adn074^eg0z2N=-8SAf`_n@`Z@pbRx@{M`+*Ng2xSLTs I<;gc801R?N*8l(j delta 183 zcmdn+I(ozF=m{GXaxMOSpF diff --git a/static/firmware/ESP32_3248S035C/firmware_BONANZA.bin b/static/firmware/ESP32_3248S035C/firmware_BONANZA.bin index c55624b3641ab331510d9f2ecf92fd7a8a612d70..919589d45c82a6d1fff8668984d6a4acb4f985d2 100644 GIT binary patch delta 182 zcmZ4RCVIh}=m{GXOhj%+EVB{v6x|oTcCK)g)P)|?7hANSXFAuv`cQe^PDK+FQftU$~L#Oy!}lIH|sE+FOxVjdvo1!6uR<_BT{ zAQl8-As`k8Vi6z~-QL6@R{K^leEa{>&uO1OSIuTPTexNMq^8#TxyP^W)!VjnLb+IA H%%eyEYQshZ delta 182 zcmZ4RCVIh}=m{GXl0P@-c6z#=>2=s<&|CR_Q$y#*va)!^zOXdb;@}dSOOqc;1#DJe zjALgpHZ?G4ZsKTf;$Q?~CLm@8Viq7~1!6WJW(Q)BJSPxy0Wmia^8hg~5c2^sKM)H5 zu^0yc_MVWPB~;5&{_X38^{2MJdKoUdsp6jFn{87<{(4U~)C$LB&`#c|a?Gwm+#uplH?X`AKW=tCZ DIc`DY delta 174 zcmaE`DCEJSkO>3|{hl()*F%u9o12GE_vjQ<25VHd@2M}`tF&7YX12GQ}^8zs+5c31E z01yiTu@DdoZx0m{dG$+iUHCowFdeVp4|Yq}8yoD%E6>y3m2%@P=Y6Ka<=-W=WHYe*Ov# FO919DL(TvI delta 183 zcmbPmCVB!8ZBW>^@=N|{w*zNgDi`KT@&8juzQ6BI>ps1AUOq-!@)hh|rhnvO3fQc` z7{|_HY-(W8+{Dq|#K8!}OhC*G#4JF}3dC$c%nrmLc}^ha0%C3;<^f_}Am#&NejpYA zVnHAl0%Bnx76D?>?M)nFxpx)cUY~c|)U)P$)20~$hwb-8Uwk)nTky&0+Qz3h%v5=h H9KQtsWJ^ZW diff --git a/static/firmware/ESP32_3248S035C/manifest.json b/static/firmware/ESP32_3248S035C/manifest.json index 264e108..35a0cdf 100644 --- a/static/firmware/ESP32_3248S035C/manifest.json +++ b/static/firmware/ESP32_3248S035C/manifest.json @@ -1,6 +1,6 @@ { "name": "BitcoinTaps PartyTap", - "version": "863500", + "version": "865875", "new_install_prompt_erase": true, "builds": [ { diff --git a/tasks.py b/tasks.py index 0c4f998..0bbb1f6 100644 --- a/tasks.py +++ b/tasks.py @@ -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( @@ -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: diff --git a/templates/partytap/index.html b/templates/partytap/index.html index 85fd8ec..637fc42 100644 --- a/templates/partytap/index.html +++ b/templates/partytap/index.html @@ -393,7 +393,7 @@
data: function () { return { tab: 'mails', - version: '863500', + version: '865875', hostname: window.location.host, protocol: window.location.protocol, location: window.location.hostname, diff --git a/views.py b/views.py index a5afe4d..b82a906 100644 --- a/views.py +++ b/views.py @@ -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 @@ -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}, - ) \ No newline at end of file + ) +