Core/tag check get (#797)

* safer tag checking

* annotate
This commit is contained in:
calle 2022-07-28 11:53:40 +02:00 committed by GitHub
parent 9a9f3ae809
commit 730add5116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -485,7 +485,8 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
) )
try: try:
tag = data["tag"] tag: str = data.get("tag")
params.update(**data)
if tag == "channelRequest": if tag == "channelRequest":
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST, status_code=HTTPStatus.BAD_REQUEST,
@ -495,10 +496,7 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
"message": "unsupported", "message": "unsupported",
}, },
) )
elif tag == "withdrawRequest":
params.update(**data)
if tag == "withdrawRequest":
params.update(kind="withdraw") params.update(kind="withdraw")
params.update(fixed=data["minWithdrawable"] == data["maxWithdrawable"]) params.update(fixed=data["minWithdrawable"] == data["maxWithdrawable"])
@ -516,8 +514,7 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
query=urlencode(qs, doseq=True) query=urlencode(qs, doseq=True)
) )
params.update(callback=urlunparse(parsed_callback)) params.update(callback=urlunparse(parsed_callback))
elif tag == "payRequest":
if tag == "payRequest":
params.update(kind="pay") params.update(kind="pay")
params.update(fixed=data["minSendable"] == data["maxSendable"]) params.update(fixed=data["minSendable"] == data["maxSendable"])
@ -535,8 +532,8 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
params.update(image=data_uri) params.update(image=data_uri)
if k == "text/email" or k == "text/identifier": if k == "text/email" or k == "text/identifier":
params.update(targetUser=v) params.update(targetUser=v)
params.update(commentAllowed=data.get("commentAllowed", 0)) params.update(commentAllowed=data.get("commentAllowed", 0))
except KeyError as exc: except KeyError as exc:
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.SERVICE_UNAVAILABLE, status_code=HTTPStatus.SERVICE_UNAVAILABLE,