I want them to turn black

This commit is contained in:
benarc
2021-10-17 18:33:29 +01:00
parent 70facdaa93
commit 1d3bb016a2
84 changed files with 899 additions and 1008 deletions
+22 -20
View File
@@ -14,14 +14,17 @@ from .crud import get_withdraw_link_by_hash, update_withdraw_link
# FOR LNURLs WHICH ARE NOT UNIQUE
@withdraw_ext.get("/api/v1/lnurl/{unique_hash}", status_code=HTTPStatus.OK, name="withdraw.api_lnurl_response")
@withdraw_ext.get(
"/api/v1/lnurl/{unique_hash}",
status_code=HTTPStatus.OK,
name="withdraw.api_lnurl_response",
)
async def api_lnurl_response(request: Request, unique_hash):
link = await get_withdraw_link_by_hash(unique_hash)
if not link:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="Withdraw link does not exist."
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
)
# return ({"status": "ERROR", "reason": "LNURL-withdraw not found."},
# HTTPStatus.OK,
@@ -39,23 +42,22 @@ async def api_lnurl_response(request: Request, unique_hash):
return link.lnurl_response(request).dict()
# CALLBACK
@withdraw_ext.get("/api/v1/lnurl/cb/{unique_hash}", name="withdraw.api_lnurl_callback")
async def api_lnurl_callback(request: Request,
unique_hash: str=Query(...),
k1: str = Query(...),
payment_request: str = Query(..., alias="pr")
):
async def api_lnurl_callback(
request: Request,
unique_hash: str = Query(...),
k1: str = Query(...),
payment_request: str = Query(..., alias="pr"),
):
link = await get_withdraw_link_by_hash(unique_hash)
now = int(datetime.now().timestamp())
if not link:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="LNURL-withdraw not found."
status_code=HTTPStatus.NOT_FOUND, detail="LNURL-withdraw not found."
)
# return (
# {"status": "ERROR", "reason": "LNURL-withdraw not found."},
@@ -73,10 +75,7 @@ async def api_lnurl_callback(request: Request,
# )
if link.k1 != k1:
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,
detail="Bad request."
)
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail="Bad request.")
# return {"status": "ERROR", "reason": "Bad request."}, HTTPStatus.OK
if now < link.open_time:
@@ -123,17 +122,21 @@ async def api_lnurl_callback(request: Request,
return {"status": "OK"}
# FOR LNURLs WHICH ARE UNIQUE
@withdraw_ext.get("/api/v1/lnurl/{unique_hash}/{id_unique_hash}", status_code=HTTPStatus.OK, name="withdraw.api_lnurl_multi_response")
@withdraw_ext.get(
"/api/v1/lnurl/{unique_hash}/{id_unique_hash}",
status_code=HTTPStatus.OK,
name="withdraw.api_lnurl_multi_response",
)
async def api_lnurl_multi_response(request: Request, unique_hash, id_unique_hash):
link = await get_withdraw_link_by_hash(unique_hash)
if not link:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="LNURL-withdraw not found."
status_code=HTTPStatus.NOT_FOUND, detail="LNURL-withdraw not found."
)
# return (
# {"status": "ERROR", "reason": "LNURL-withdraw not found."},
@@ -158,8 +161,7 @@ async def api_lnurl_multi_response(request: Request, unique_hash, id_unique_hash
found = True
if not found:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail="LNURL-withdraw not found."
status_code=HTTPStatus.NOT_FOUND, detail="LNURL-withdraw not found."
)
# return (
# {"status": "ERROR", "reason": "LNURL-withdraw not found."},