mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-11 04:52:34 +02:00
reducing the PR
This commit is contained in:
@@ -112,14 +112,8 @@ async def get_card_by_external_id(external_id: str) -> Optional[Card]:
|
|||||||
return Card.parse_obj(card)
|
return Card.parse_obj(card)
|
||||||
|
|
||||||
|
|
||||||
async def get_card_by_otp(otp: str, half: bool = False) -> Optional[Card]:
|
async def get_card_by_otp(otp: str) -> Optional[Card]:
|
||||||
if half and len(otp) == 16:
|
row = await db.fetchone("SELECT * FROM boltcards.cards WHERE otp = ?", (otp,))
|
||||||
otp = "%" + otp
|
|
||||||
row = await db.fetchone(
|
|
||||||
"SELECT * FROM boltcards.cards WHERE otp LIKE ?", (otp,)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
row = await db.fetchone("SELECT * FROM boltcards.cards WHERE otp = ?", (otp,))
|
|
||||||
if not row:
|
if not row:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@@ -3,13 +3,11 @@ import secrets
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from embit import bech32, compact
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from fastapi.params import Depends, Query
|
from fastapi.params import Depends, Query
|
||||||
from lnurl import encode as lnurl_encode # type: ignore
|
from lnurl import encode as lnurl_encode # type: ignore
|
||||||
from lnurl.types import LnurlPayMetadata # type: ignore
|
from lnurl.types import LnurlPayMetadata # type: ignore
|
||||||
from loguru import logger
|
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
@@ -118,7 +116,6 @@ async def lnurl_callback(
|
|||||||
max_sat=card.tx_limit,
|
max_sat=card.tx_limit,
|
||||||
extra={"tag": "boltcard", "tag": hit.id},
|
extra={"tag": "boltcard", "tag": hit.id},
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"status": "OK"}
|
return {"status": "OK"}
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return {"status": "ERROR", "reason": f"Payment failed - {exc}"}
|
return {"status": "ERROR", "reason": f"Payment failed - {exc}"}
|
||||||
|
Reference in New Issue
Block a user