diff options
| author | Adam Soltys <[email protected]> | 2024-11-21 16:31:25 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-21 16:31:31 -0800 |
| commit | 38660e024c055952180bfa3f9067274cf2e0d6ed (patch) | |
| tree | ded80bc71beab042a26b811cf5e7681af3379338 /src/lib | |
| parent | d946ec9dbcba7c8e49d2e5b4221cb11a7f726528 (diff) | |
| download | coinos-ui-38660e024c055952180bfa3f9067274cf2e0d6ed.tar.gz coinos-ui-38660e024c055952180bfa3f9067274cf2e0d6ed.zip | |
ecash requests
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/nostr.ts | 3 | ||||
| -rw-r--r-- | src/lib/parse.ts | 29 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/nostr.ts b/src/lib/nostr.ts index 2e3ea142..bba46ef4 100644 --- a/src/lib/nostr.ts +++ b/src/lib/nostr.ts @@ -140,7 +140,8 @@ type SignParams = { }; export const sign = async ({ event, user }: SignParams) => { - event = finalizeEvent(event, await getPrivateKey(user)); + const sk = await getPrivateKey(user); + event = finalizeEvent(event, sk); }; export const send = (event: EventTemplate) => { diff --git a/src/lib/parse.ts b/src/lib/parse.ts index e4bd3497..03d21943 100644 --- a/src/lib/parse.ts +++ b/src/lib/parse.ts @@ -1,26 +1,17 @@ import { PUBLIC_DOMAIN } from "$env/static/public"; -import { get, sats, isLiquid, post } from "$lib/utils"; +import { get, isLiquid, auth, post, sats } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; import bip21 from "bip21"; import { validate } from "bitcoin-address-validation"; export default async (s, host) => { if (!s) return; - let t = s; - - if (t.includes("lightning=")) { - const url = new URL(t); - const params = new URLSearchParams(url.search); - t = params.get("lightning"); - } - - if (t.startsWith("http")) redirect(307, t); - if (t.startsWith(host)) redirect(307, `http://${t}`); - + let t = s.trim(); let amount; let user; - t = t.trim(); + if (t.startsWith("http")) redirect(307, t); + if (t.startsWith(host)) redirect(307, `http://${t}`); if (t.startsWith("lightning:")) t = t.replace("lightning:", ""); if (t.endsWith(`@${PUBLIC_DOMAIN}`)) t = t.split("@")[0]; @@ -30,8 +21,6 @@ export default async (s, host) => { } catch (e) {} } - if (t.includes("/fund")) redirect(307, t.substring(t.indexOf("/fund"))); - // lightning if (t.toLowerCase().startsWith("lightning:")) t = t.toLowerCase().replace("lightning:", ""); @@ -44,6 +33,12 @@ export default async (s, host) => { redirect(307, `/send/lightning/${t}`); } + if (t.includes("lightning=")) { + const url = new URL(t); + const params = new URLSearchParams(url.search); + t = params.get("lightning"); + } + if (t.toLowerCase().startsWith("ln")) { try { await get(`/invoice/${t}`); @@ -70,6 +65,8 @@ export default async (s, host) => { redirect(307, `/ecash/${id}`); } + if (t.startsWith("creq")) redirect(307, `/send/ecash/${t}`); + // user try { user = await get(`/users/${t.split("/")[0]}`); @@ -79,6 +76,8 @@ export default async (s, host) => { if (user) redirect(307, `/pay/${t}`); let fund; + if (t.includes("/fund")) redirect(307, t.substring(t.indexOf("/fund"))); + try { fund = await get(`/fund/${t}`); } catch (e) {} |
