recording card tapping

This commit is contained in:
iWarpBTC
2022-08-14 10:52:58 -06:00
committed by Lee Salminen
parent 4fab2d3101
commit 3cb62d1899
5 changed files with 102 additions and 7 deletions
+10 -1
View File
@@ -19,6 +19,7 @@ from lnbits.extensions.withdraw import get_withdraw_link
from . import boltcards_ext
from .nxp424 import decryptSUN, getSunMAC
from .crud import (
create_hit,
get_all_cards,
get_cards,
get_card,
@@ -43,7 +44,7 @@ async def api_cards(
@boltcards_ext.post("/api/v1/cards", status_code=HTTPStatus.CREATED)
@boltcards_ext.put("/api/v1/cards/{card_id}", status_code=HTTPStatus.OK)
async def api_link_create_or_update(
req: Request,
# req: Request,
data: CreateCardData,
card_id: str = None,
wallet: WalletTypeInfo = Depends(require_admin_key),
@@ -157,5 +158,13 @@ async def api_scane(
await update_card_counter(counter_int, card.id)
ip = request.client.host
if request.headers['x-real-ip']:
ip = request.headers['x-real-ip']
elif request.headers['x-forwarded-for']:
ip = request.headers['x-forwarded-for']
await create_hit(card.id, ip, request.headers['user-agent'], card.counter, counter_int)
link = await get_withdraw_link(card.withdraw, 0)
return link.lnurl_response(request)