Fixes claiming LNURL (#2924)
This commit is contained in:
parent
0efb52664e
commit
e134c5c7b9
3 changed files with 20 additions and 10 deletions
|
|
@ -435,13 +435,12 @@ async def lnurlwallet(request: Request, lightning: str = ""):
|
||||||
claim their satoshis and get an instant LNbits wallet! lnbits/withdraw docs
|
claim their satoshis and get an instant LNbits wallet! lnbits/withdraw docs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
lightning_param = lightning
|
if not lightning:
|
||||||
if not lightning_param:
|
|
||||||
return {"status": "ERROR", "reason": "lightning parameter not provided."}
|
return {"status": "ERROR", "reason": "lightning parameter not provided."}
|
||||||
if not settings.lnbits_allow_new_accounts:
|
if not settings.lnbits_allow_new_accounts:
|
||||||
return {"status": "ERROR", "reason": "New accounts are not allowed."}
|
return {"status": "ERROR", "reason": "New accounts are not allowed."}
|
||||||
|
|
||||||
lnurl = lnurl_decode(lightning_param)
|
lnurl = lnurl_decode(lightning)
|
||||||
|
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
res1 = await client.get(lnurl, timeout=2)
|
res1 = await client.get(lnurl, timeout=2)
|
||||||
|
|
@ -458,7 +457,7 @@ async def lnurlwallet(request: Request, lightning: str = ""):
|
||||||
detail="Invalid lnurl. Expected maxWithdrawable",
|
detail="Invalid lnurl. Expected maxWithdrawable",
|
||||||
)
|
)
|
||||||
account = await create_user_account()
|
account = await create_user_account()
|
||||||
wallet = await create_wallet(user_id=account.id)
|
wallet = account.wallets[0]
|
||||||
payment = await create_invoice(
|
payment = await create_invoice(
|
||||||
wallet_id=wallet.id,
|
wallet_id=wallet.id,
|
||||||
amount=data1.get("maxWithdrawable") / 1000,
|
amount=data1.get("maxWithdrawable") / 1000,
|
||||||
|
|
@ -467,7 +466,8 @@ async def lnurlwallet(request: Request, lightning: str = ""):
|
||||||
url = data1.get("callback")
|
url = data1.get("callback")
|
||||||
params = {"k1": data1.get("k1"), "pr": payment.bolt11}
|
params = {"k1": data1.get("k1"), "pr": payment.bolt11}
|
||||||
callback = url + ("&" if urlparse(url).query else "?") + urlencode(params)
|
callback = url + ("&" if urlparse(url).query else "?") + urlencode(params)
|
||||||
res2 = await client.get(callback, timeout=2)
|
|
||||||
|
res2 = await client.get(callback, timeout=5)
|
||||||
res2.raise_for_status()
|
res2.raise_for_status()
|
||||||
|
|
||||||
return RedirectResponse(
|
return RedirectResponse(
|
||||||
|
|
|
||||||
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -131,10 +131,20 @@ const routes = [
|
||||||
path: '/wallet',
|
path: '/wallet',
|
||||||
name: 'Wallet',
|
name: 'Wallet',
|
||||||
component: DynamicComponent,
|
component: DynamicComponent,
|
||||||
props: route => ({
|
props: route => {
|
||||||
fetchUrl: `/wallet${route.query.wal ? `?wal=${route.query.wal}` : ''}`,
|
let fetchUrl = '/wallet'
|
||||||
scripts: ['/static/js/wallet.js']
|
if (Object.keys(route.query).length > 0) {
|
||||||
})
|
fetchUrl += '?'
|
||||||
|
for (const [key, value] of Object.entries(route.query)) {
|
||||||
|
fetchUrl += `${key}=${value}&`
|
||||||
|
}
|
||||||
|
fetchUrl = fetchUrl.slice(0, -1) // remove last &
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
fetchUrl,
|
||||||
|
scripts: ['/static/js/wallet.js']
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/admin',
|
path: '/admin',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue