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")
|
@core_app.post("/api/v1/payments/decode")
|
||||||
async def api_payments_decode(data: str = Query(None)):
|
async def api_payments_decode(data: str = Query(None)):
|
||||||
try:
|
try:
|
||||||
if g.data["data"][:5] == "LNURL":
|
print(data["data"][:5])
|
||||||
url = lnurl.decode(g.data["data"])
|
if data["data"][:5] == "LNURL":
|
||||||
|
url = lnurl.decode(data["data"])
|
||||||
return {"domain": url}
|
return {"domain": url}
|
||||||
else:
|
else:
|
||||||
invoice = bolt11.decode(g.data["data"])
|
invoice = bolt11.decode(data["data"])
|
||||||
return {
|
return {
|
||||||
"payment_hash": invoice.payment_hash,
|
"payment_hash": invoice.payment_hash,
|
||||||
"amount_msat": invoice.amount_msat,
|
"amount_msat": invoice.amount_msat,
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,6 @@
|
||||||
|
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="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">
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
{{ col.value }}
|
{{ col.value }}
|
||||||
</q-td>
|
</q-td>
|
||||||
|
|
@ -213,7 +201,7 @@
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(data)
|
console.log(response.data)
|
||||||
self.lnurlpayouts.push(maplnurlpayout(response.data))
|
self.lnurlpayouts.push(maplnurlpayout(response.data))
|
||||||
self.formDialog.show = false
|
self.formDialog.show = false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,17 @@ async def api_lnurlpayouts(
|
||||||
@lnurlpayout_ext.post("/api/v1/lnurlpayouts", status_code=HTTPStatus.CREATED)
|
@lnurlpayout_ext.post("/api/v1/lnurlpayouts", status_code=HTTPStatus.CREATED)
|
||||||
async def api_lnurlpayout_create(
|
async def api_lnurlpayout_create(
|
||||||
data: CreateLnurlPayoutData, wallet: WalletTypeInfo = Depends(get_key_type)
|
data: CreateLnurlPayoutData, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||||
):
|
):
|
||||||
url = api_payments_decode(data.lnurlpay)
|
try:
|
||||||
if url[0:4] != "http":
|
url = await api_payments_decode({"data": data.lnurlpay})
|
||||||
raise PermissionError("Not valid LNURL")
|
|
||||||
lnurlpayout = await create_lnurlpayout(wallet_id=wallet.wallet.id, data=data)
|
if str(url["domain"])[0:4] != "http":
|
||||||
return lnurlpayout.dict()
|
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}")
|
@lnurlpayout_ext.delete("/api/v1/lnurlpayouts/{lnurlpayout_id}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue