diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/ln/[lnurl]/+page.server.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/routes/(app)/ln/[lnurl]/+page.server.ts b/src/routes/(app)/ln/[lnurl]/+page.server.ts index c113e03f..405dc4b3 100644 --- a/src/routes/(app)/ln/[lnurl]/+page.server.ts +++ b/src/routes/(app)/ln/[lnurl]/+page.server.ts @@ -11,6 +11,20 @@ export async function load({ params, parent }) { try { const { lnurl } = params; data = await get(`/decode?text=${lnurl}`); + let { callback, minSendable, maxSendable, comment, tag } = data; + if (tag === "payRequest" && minSendable === maxSendable) { + minSendable = Math.round(minSendable / 1000); + maxSendable = Math.round(maxSendable / 1000); + const amount = minSendable; + + let url = `${callback}?amount=${amount * 1000}`; + if (comment) url += `&comment=${comment}`; + + const { pr } = await fetch(url).then((r) => r.json()); + let path = `/send/lightning/${pr}`; + if (comment) path += `/${encodeURIComponent(comment)}`; + redirect(307, path); + } } catch (e) { const { message } = e as Error; error(500, message); |
