Added check fixed LNURL decode
This commit is contained in:
parent
2490b218b1
commit
fa23be7657
3 changed files with 16 additions and 22 deletions
|
|
@ -466,11 +466,12 @@ async def api_lnurlscan(code: str):
|
|||
@core_app.post("/api/v1/payments/decode")
|
||||
async def api_payments_decode(data: str = Query(None)):
|
||||
try:
|
||||
if g.data["data"][:5] == "LNURL":
|
||||
url = lnurl.decode(g.data["data"])
|
||||
print(data["data"][:5])
|
||||
if data["data"][:5] == "LNURL":
|
||||
url = lnurl.decode(data["data"])
|
||||
return {"domain": url}
|
||||
else:
|
||||
invoice = bolt11.decode(g.data["data"])
|
||||
invoice = bolt11.decode(data["data"])
|
||||
return {
|
||||
"payment_hash": invoice.payment_hash,
|
||||
"amount_msat": invoice.amount_msat,
|
||||
|
|
|
|||
|
|
@ -41,18 +41,6 @@
|
|||
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props">
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
unelevated
|
||||
dense
|
||||
size="xs"
|
||||
icon="launch"
|
||||
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||
type="a"
|
||||
:href="props.row.lnurlpayout"
|
||||
target="_blank"
|
||||
></q-btn>
|
||||
</q-td>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
{{ col.value }}
|
||||
</q-td>
|
||||
|
|
@ -213,7 +201,7 @@
|
|||
data
|
||||
)
|
||||
.then(function (response) {
|
||||
console.log(data)
|
||||
console.log(response.data)
|
||||
self.lnurlpayouts.push(maplnurlpayout(response.data))
|
||||
self.formDialog.show = false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -29,11 +29,16 @@ async def api_lnurlpayouts(
|
|||
async def api_lnurlpayout_create(
|
||||
data: CreateLnurlPayoutData, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
url = api_payments_decode(data.lnurlpay)
|
||||
if url[0:4] != "http":
|
||||
raise PermissionError("Not valid LNURL")
|
||||
lnurlpayout = await create_lnurlpayout(wallet_id=wallet.wallet.id, data=data)
|
||||
return lnurlpayout.dict()
|
||||
try:
|
||||
url = await api_payments_decode({"data": data.lnurlpay})
|
||||
|
||||
if str(url["domain"])[0:4] != "http":
|
||||
raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="Failed to save LNURLPayout")
|
||||
lnurlpayout = await create_lnurlpayout(wallet_id=wallet.wallet.id, data=data)
|
||||
return lnurlpayout.dict()
|
||||
except Exception:
|
||||
raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="Failed to save LNURLPayout")
|
||||
|
||||
|
||||
|
||||
@lnurlpayout_ext.delete("/api/v1/lnurlpayouts/{lnurlpayout_id}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue