From e28fed9f2243509a8c8c84e836cfa38cbd47a3cf Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 3 May 2025 08:48:56 -0700 Subject: fund fixes --- src/routes/(app)/fund/[id]/+page.svelte | 18 ++++++++++-------- src/routes/(app)/fund/[id]/access/+page.svelte | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 6cb3b05d..f1a1838e 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -69,13 +69,15 @@ {/if} - - - {$t("funds.manage")} - + {#if (user && !managers.length) || managers.some((m) => m.id === user?.id)} + + + {$t("funds.manage")} + + {/if}
@@ -87,7 +89,7 @@
- {#if !managers.length || managers.some((m) => m.id === user.id)} + {#if !managers.length || managers.some((m) => m.id === user?.id)}
{/if} - - - +
+ + + diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts index 2c2807bd..8c6d6a8d 100644 --- a/src/routes/(static)/register/+page.server.ts +++ b/src/routes/(static)/register/+page.server.ts @@ -1,5 +1,5 @@ -import { fd, get, login, post } from "$lib/utils"; -import { fail, redirect } from "@sveltejs/kit"; +import { fd, get, register } from "$lib/utils"; +import { redirect } from "@sveltejs/kit"; export const load = async ({ parent }) => { const { user } = await parent(); @@ -14,39 +14,13 @@ export const load = async ({ parent }) => { export const actions = { default: async ({ cookies, request }) => { const ip = request.headers.get("cf-connecting-ip"); - const form = await fd(request); - let { picture, username, password, pubkey, loginRedirect } = form; - const user = { picture, username, password, pubkey }; - let error; - + const { picture, username, password } = form; + let { loginRedirect } = form; if (loginRedirect === "undefined") loginRedirect = undefined; - let sk; - try { - ({ sk } = await post("/register", { user }, { "cf-connecting-ip": ip })); - } catch (e) { - ({ message: error } = e as Error); - } - - try { - await login(user, cookies, ip); - error = null; - } catch (e) { - const { message } = e as Error; - error ||= message; - } - - const expires = new Date(); - expires.setSeconds(expires.getSeconds() + 21000000); - cookies.set("sk", sk, { - path: "/", - expires, - httpOnly: false, - sameSite: "lax", - }); - - if (error) return fail(400, { error }); + const user = { picture, username, password }; + await register(user, ip, cookies, loginRedirect); redirect(303, loginRedirect || `/${user.username}`); }, }; -- cgit v1.2.3 From 888aa32a1467fa752ff543149470d3275c7e8915 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 8 Jul 2025 02:09:42 -0700 Subject: sweep success --- src/routes/(app)/fund/[id]/sweep/+page.svelte | 34 ++++++++++------------ .../send/fund/[...name]/[...amount]/+page.svelte | 29 ++++++++++++++---- 2 files changed, 39 insertions(+), 24 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte index 0523b85a..986a84bb 100644 --- a/src/routes/(app)/fund/[id]/sweep/+page.svelte +++ b/src/routes/(app)/fund/[id]/sweep/+page.svelte @@ -1,35 +1,33 @@ -
-
- -
-

- {$t("payments.fundsClaimed")} -

-

- {f(toFiat(amount, rate), currency)} -

-

- ⚡️{s(amount)} -

+
+
-
-
+
+
-
+
{$t("payments.tapAnywhere")}
diff --git a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte index 314be3ef..652e0885 100644 --- a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte @@ -7,10 +7,11 @@ import { pin } from "$lib/store"; import handler from "$lib/handler"; import { s } from "$lib/utils"; + import { applyAction, deserialize } from "$app/forms"; let { data, form } = $props(); - let { amount } = $state(data); - let { balance, currency } = data.user; + let { amount, user } = $state(data); + let { balance, currency } = $derived(user); let { name, rate } = $derived(data); let loading = $state(); let fiat = $state(); @@ -22,11 +23,22 @@ if (form?.message?.includes("pin")) $pin = undefined; loading = false; }); + let formElement = $state(); - let setMax = (e) => { + let setMax = async (e) => { e.preventDefault(); - fiat = false; - amount = balance; + let body = new FormData(formElement); + body.set("fiat", false); + body.set("amount", user.balance); + + const response = await fetch(formElement.action, { + method: "POST", + body, + }); + + const result = deserialize(await response.text()); + if (result.type === "success") await invalidateAll(); + applyAction(result); }; @@ -39,7 +51,12 @@
-
+ -- cgit v1.2.3 From 2d9d01d6e8d63ee223078874aa3b101b016367ac Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 8 Jul 2025 10:16:22 -0700 Subject: auto pay --- src/locales/en.json | 3 ++ src/routes/(app)/fund/[id]/+page.svelte | 2 +- src/routes/(app)/invoice/[id]/tip/+page.server.ts | 21 ++++++++++-- src/routes/(app)/send/[...text]/+page.svelte | 37 +++++++++++++++++----- src/routes/(app)/send/invoice/[id]/+page.server.ts | 14 ++++++-- src/routes/(app)/send/invoice/[id]/+page.svelte | 21 +++++++++++- src/routes/(app)/settings/account/+page.svelte | 15 ++++++++- 7 files changed, 97 insertions(+), 16 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/locales/en.json b/src/locales/en.json index c4ca5e17..922d24b3 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -296,6 +296,8 @@ "placeholder": "Enter an address, invoice or username" }, "settings": { + "tip": "Default tip", + "tipDesc": "Default tip percentage when auto-paying trusted users", "nostr": "Nostr", "name": "Name", "integrations": "Integrations", @@ -398,6 +400,7 @@ } }, "payments": { + "trustUser": "Send and enable auto-pay", "sweep": "Sweep link", "lockedBalance": "Locked balance", "insufficientFunds": "Insufficient funds", diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 614616af..7f465512 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -112,7 +112,7 @@
{$t("payments.shareLink")}
{/if} - + {/each} diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 3ef933d4..4bb7ded5 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -2,11 +2,19 @@ import getRates from "$lib/rates"; import { auth, fd, get, post, types } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; -export async function load({ cookies, params: { id }, parent }) { +export async function load({ cookies, depends, params: { id }, parent }) { + depends("app:trust"); const { user } = await parent(); const aid = cookies.get("aid") || user.id; - const invoice = await get(`/invoice/${id}`); + let invoice = await get(`/invoice/${id}`); + + const trust = await get("/trust", auth(cookies)); + const trusted = trust.includes(invoice.uid); + if (trusted) { + const p = await post("/payments", invoice, auth(cookies)); + redirect(307, `/sent/${p.id}`); + } if (invoice.amount && invoice.prompt && invoice.tip === null) redirect(307, `/invoice/${id}/tip`); @@ -31,7 +39,7 @@ export async function load({ cookies, params: { id }, parent }) { const invoiceRate = rates[invoice.currency]; const { balance } = await get(`/account/${aid}`, auth(cookies)); - return { balance, invoice, user, rate, invoiceRate }; + return { balance, invoice, user, rate, invoiceRate, trusted }; } export const actions = { diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 7d167f41..9aac5c8d 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -1,4 +1,5 @@
+ {#if user?.fresh} +
+

{$t("user.settings.welcome")}

+
+ {$t("user.settings.yourUsername")} {user?.username} + {#if $password} + {$t("user.settings.yourPassword")} + {$password}{/if} +
+ +
{$t("user.settings.clickBelow")}
+ + + + Settings +
+ {/if} {#if user?.id && user.id === subject.id}
{#each accounts as account, i} @@ -55,6 +73,8 @@ {/if}
+ +
{#if user?.username !== subject.username && (!subject.anon || subject.lud16)} + import { onMount } from "svelte"; + import { password } from "$lib/store"; import Amount from "$comp/Amount.svelte"; import Success from "$comp/Success.svelte"; import { scale } from "svelte/transition"; @@ -9,9 +11,11 @@ let { data } = $props(); - let { amount, id, user, rate, rates } = data; + let { amount, id, user, rate, rates, password: pw } = data; let { currency } = user; let locale = $derived(loc(user)); + + onMount(() => ($password = pw));
diff --git a/src/routes/(app)/funder/+page.svelte b/src/routes/(app)/funder/+page.svelte new file mode 100644 index 00000000..e6549360 --- /dev/null +++ b/src/routes/(app)/funder/+page.svelte @@ -0,0 +1,55 @@ + + +HI + +{#if here}HERE{/if} +{#if ready}go{/if} +{#if success}done{/if} diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts index de24c639..286d7c35 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts @@ -8,20 +8,22 @@ export async function load({ cookies, parent }) { let { invoice, subject, user } = await parent(); if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`); - const trust = await get("/trust", auth(cookies)); - const trusted = trust.includes(invoice.uid); - if (trusted) { - if (invoice.prompt && invoice.tip === null && user.tip > 0) { - invoice.tip = Math.round(invoice.amount * (user.tip / 100)); - invoice = await post( - "/invoice", - { invoice, user: subject }, - auth(cookies), - ); - } + if (user) { + const trust = await get("/trust", auth(cookies)); + const trusted = trust.includes(invoice.uid); + if (trusted) { + if (invoice.prompt && invoice.tip === null && user.tip > 0) { + invoice.tip = Math.round(invoice.amount * (user.tip / 100)); + invoice = await post( + "/invoice", + { invoice, user: subject }, + auth(cookies), + ); + } - const p = await post("/payments", invoice, auth(cookies)); - redirect(307, `/sent/${p.id}`); + const p = await post("/payments", invoice, auth(cookies)); + redirect(307, `/sent/${p.id}`); + } } const rate = rates[subject?.currency]; diff --git a/src/routes/(app)/settings/profile/+page.svelte b/src/routes/(app)/settings/profile/+page.svelte index bee50d39..ec9855d0 100644 --- a/src/routes/(app)/settings/profile/+page.svelte +++ b/src/routes/(app)/settings/profile/+page.svelte @@ -3,16 +3,18 @@ import { avatar, banner as bannerStore } from "$lib/store"; import { t } from "$lib/translations"; import { page } from "$app/stores"; + import PasswordInput from "$comp/PasswordInput.svelte"; let { data } = $props(); let { user } = $derived(data); let { id } = user; - let { about, banner, picture, display, username } = - $state(user); + let { about, banner, picture, display, username } = $state(user); let avatarFile, avatarInput = $state(), bannerFile, + password = $state(), + revealPassword = $state(), bannerInput = $state(); let selectAvatar = () => avatarInput.click(); @@ -64,6 +66,16 @@
+ + +
+ + + +
+
- - -
- - - -
Date: Fri, 11 Jul 2025 11:22:27 -0700 Subject: gift link page --- src/locales/en.json | 22 ++++++++------ src/routes/(app)/fund/[id]/+layout.server.ts | 12 ++++++++ src/routes/(app)/fund/[id]/+page.server.ts | 13 +------- src/routes/(app)/fund/[id]/+page.svelte | 11 +++---- src/routes/(app)/fund/[id]/gift/+page.server.ts | 7 +++++ src/routes/(app)/fund/[id]/gift/+page.svelte | 40 +++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 src/routes/(app)/fund/[id]/+layout.server.ts create mode 100644 src/routes/(app)/fund/[id]/gift/+page.server.ts create mode 100644 src/routes/(app)/fund/[id]/gift/+page.svelte (limited to 'src/routes/(app)/fund') diff --git a/src/locales/en.json b/src/locales/en.json index 88de69da..6045b00d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -296,8 +296,8 @@ "placeholder": "Enter an address, invoice or username" }, "settings": { - "tip": "Default tip", - "tipDesc": "Default tip percentage when auto-paying trusted users", + "tip": "Default tip", + "tipDesc": "Default tip percentage when auto-paying trusted users", "nostr": "Nostr", "name": "Name", "integrations": "Integrations", @@ -351,11 +351,11 @@ "username": "Username", "email": "Email", "newPassword": "New Password", - "newPasswordDesc": "(Leave blank to keep unchanged)", - "yourUsername": "Your username is", - "yourPassword": "and your password is", - "welcome": "Welcome!", - "clickBelow": "Click below to finish setting up your account", + "newPasswordDesc": "(Leave blank to keep unchanged)", + "yourUsername": "Your username is", + "yourPassword": "and your password is", + "welcome": "Welcome!", + "clickBelow": "Click below to finish setting up your account", "about": "About", "aboutPlaceholder": "A little something about you or your business address and hours", "emailNotifications": "Email Notifications", @@ -405,8 +405,12 @@ } }, "payments": { - "trustUser": "Send and enable auto-pay", - "sweep": "Sweep link", + "trustUser": "Send and enable auto-pay", + "gift": "Gift all funds", + "giftLink": "Gift link", + "giftDesc1": "Whoever opens the link below will receive all the available funds.", + "giftDesc2": "If they are logged in, the funds will go to their account, otherwise a new account will be generated.", + "sweep": "Sweep link", "lockedBalance": "Locked balance", "insufficientFunds": "Insufficient funds", "pending": "Pending", diff --git a/src/routes/(app)/fund/[id]/+layout.server.ts b/src/routes/(app)/fund/[id]/+layout.server.ts new file mode 100644 index 00000000..3669eb7d --- /dev/null +++ b/src/routes/(app)/fund/[id]/+layout.server.ts @@ -0,0 +1,12 @@ +import getRates from "$lib/rates"; +import { get } from "$lib/utils"; + +export const load = async ({ depends, params: { id }, parent }) => { + depends("app:payments"); + const data = await get(`/fund/${id}`); + data.managers = await get(`/fund/${id}/managers`); + const rates = await getRates(); + const { user } = await parent(); + data.rate = rates[user?.currency || "USD"]; + return data; +}; diff --git a/src/routes/(app)/fund/[id]/+page.server.ts b/src/routes/(app)/fund/[id]/+page.server.ts index a4f402af..cd2bd979 100644 --- a/src/routes/(app)/fund/[id]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/+page.server.ts @@ -1,17 +1,6 @@ -import getRates from "$lib/rates"; -import { auth, get, post } from "$lib/utils"; +import { auth, post } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export const load = async ({ depends, params: { id }, parent }) => { - depends("app:payments"); - const data = await get(`/fund/${id}`); - data.managers = await get(`/fund/${id}/managers`); - const rates = await getRates(); - const { user } = await parent(); - data.rate = rates[user?.currency || "USD"]; - return data; -}; - export const actions = { default: async ({ cookies, locals, params }) => { const { user } = locals; diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 7f465512..da869fed 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -111,14 +111,11 @@ >
{$t("payments.shareLink")}
- +
{$t("payments.giftLink")}
+ diff --git a/src/routes/(app)/fund/[id]/gift/+page.server.ts b/src/routes/(app)/fund/[id]/gift/+page.server.ts new file mode 100644 index 00000000..50be31f7 --- /dev/null +++ b/src/routes/(app)/fund/[id]/gift/+page.server.ts @@ -0,0 +1,7 @@ +export const load = async ({ params, parent }) => { + const p = await parent(); + console.log(p); + const { amount, rate } = p; + const { id } = params; + return { amount, id, rate }; +}; diff --git a/src/routes/(app)/fund/[id]/gift/+page.svelte b/src/routes/(app)/fund/[id]/gift/+page.svelte new file mode 100644 index 00000000..ed38c06d --- /dev/null +++ b/src/routes/(app)/fund/[id]/gift/+page.svelte @@ -0,0 +1,40 @@ + + +
+

{$t("payments.gift")}

+ + + +
+

{$t("payments.giftDesc1")}

+

{$t("payments.giftDesc2")}

+
+ +
+ + + + + +
+
-- cgit v1.2.3 From c95e08ff4e582c38489e46414d0e36bbc21e7ea1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 12 Jul 2025 11:45:44 -0700 Subject: gift wrap --- src/routes/(app)/fund/[id]/gift/+page.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/gift/+page.svelte b/src/routes/(app)/fund/[id]/gift/+page.svelte index ed38c06d..7c65d314 100644 --- a/src/routes/(app)/fund/[id]/gift/+page.svelte +++ b/src/routes/(app)/fund/[id]/gift/+page.svelte @@ -23,14 +23,14 @@

{$t("payments.giftDesc2")}

-
+
-- cgit v1.2.3 From 4fc61539d923cdee874b07a5f1576dad11bd091a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 18 Jul 2025 08:40:39 -0700 Subject: sweep fiat amounts --- src/routes/(app)/fund/[id]/sweep/+page.server.ts | 31 ----------------- src/routes/(app)/fund/[id]/sweep/+page.svelte | 37 -------------------- .../fund/[id]/sweep/[...amount]/+page.server.ts | 40 ++++++++++++++++++++++ .../(app)/fund/[id]/sweep/[...amount]/+page.svelte | 37 ++++++++++++++++++++ 4 files changed, 77 insertions(+), 68 deletions(-) delete mode 100644 src/routes/(app)/fund/[id]/sweep/+page.server.ts delete mode 100644 src/routes/(app)/fund/[id]/sweep/+page.svelte create mode 100644 src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts create mode 100644 src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/+page.server.ts deleted file mode 100644 index d8415ca4..00000000 --- a/src/routes/(app)/fund/[id]/sweep/+page.server.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { randomName, randomPassword } from "$lib/random"; -import getRates from "$lib/rates"; -import { auth, get, post, register } from "$lib/utils"; -import { redirect } from "@sveltejs/kit"; - -export async function load({ cookies, request, params, parent }) { - let { user } = await parent(); - const { id } = params; - const { amount } = await get(`/fund/${id}`); - const rates = await getRates(); - const rate = rates[user?.currency || "USD"]; - - const username = randomName(); - const password = randomPassword(); - - if (!amount) redirect(307, `/fund/${id}`); - if (!user) { - const ip = request.headers.get("cf-connecting-ip"); - - user = { - username, - password, - fresh: true, - }; - - await register(user, ip, cookies, `/fund/${id}/sweep`); - } - - await post("/take", { amount, id }, auth(cookies)); - return { amount, id, rate, rates, password }; -} diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte deleted file mode 100644 index adba77ae..00000000 --- a/src/routes/(app)/fund/[id]/sweep/+page.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -
- -
- -
-
-
- -
- {$t("payments.tapAnywhere")} -
diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts new file mode 100644 index 00000000..61a66fd2 --- /dev/null +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -0,0 +1,40 @@ +import { randomName, randomPassword } from "$lib/random"; +import getRates from "$lib/rates"; +import { auth, get, post, register, sats } from "$lib/utils"; +import { error, redirect } from "@sveltejs/kit"; + +export async function load({ cookies, request, params, parent }) { + let { user } = await parent(); + const { id } = params; + let [amount, currency] = params.amount.split("/"); + + const rates = await getRates(); + const rate = rates[user?.currency || "USD"]; + if (currency && !rate) error(500, "Invalid currency symbol"); + + if (!amount) { + const balance = await get(`/fund/${id}`); + amount = balance.amount; + } else if (currency) { + amount = (amount * sats) / rate; + } + + const username = randomName(); + const password = randomPassword(); + + if (!amount) redirect(307, `/fund/${id}`); + if (!user) { + const ip = request.headers.get("cf-connecting-ip"); + + user = { + username, + password, + fresh: true, + }; + + await register(user, ip, cookies, `/fund/${id}/sweep`); + } + + await post("/take", { amount, id }, auth(cookies)); + return { amount, id, rate, rates, password }; +} diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte new file mode 100644 index 00000000..adba77ae --- /dev/null +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte @@ -0,0 +1,37 @@ + + +
+ +
+ + +
+
+ +
+ {$t("payments.tapAnywhere")} +
-- cgit v1.2.3 From 2ebe1be60829be66936adf8cca35c239e6d16e7a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 18 Jul 2025 10:09:27 -0700 Subject: remove log --- src/routes/(app)/fund/[id]/gift/+page.server.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/gift/+page.server.ts b/src/routes/(app)/fund/[id]/gift/+page.server.ts index 50be31f7..bd39d82b 100644 --- a/src/routes/(app)/fund/[id]/gift/+page.server.ts +++ b/src/routes/(app)/fund/[id]/gift/+page.server.ts @@ -1,6 +1,5 @@ export const load = async ({ params, parent }) => { const p = await parent(); - console.log(p); const { amount, rate } = p; const { id } = params; return { amount, id, rate }; -- cgit v1.2.3 From f063e6a88999f1fe4d9ed2900b90efba1bcf1ac5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 18 Jul 2025 13:03:59 -0700 Subject: manager delete --- src/routes/(app)/fund/[id]/access/+page.server.ts | 3 --- src/routes/(app)/fund/[id]/access/+page.svelte | 12 ++++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts index c38cb29b..36191643 100644 --- a/src/routes/(app)/fund/[id]/access/+page.server.ts +++ b/src/routes/(app)/fund/[id]/access/+page.server.ts @@ -11,11 +11,8 @@ export const actions = { const form = await fd(request); try { - console.log("SUBMITTING", form); const managers = await post("/fund/managers", form, auth(cookies)); - console.log(managers); - return { managers }; } catch (e) { const { message } = e as Error; diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte index a2ea9dff..23a829a9 100644 --- a/src/routes/(app)/fund/[id]/access/+page.svelte +++ b/src/routes/(app)/fund/[id]/access/+page.svelte @@ -6,10 +6,14 @@ let { data } = $props(); let { id, managers } = $derived(data); + let m = $state(data.managers); let username = $state(); - let del = async ({ id }) => { + let del = async (e, user) => { + e.preventDefault(); try { - await post("/post/fund/access/delete", { id }); + m = await post(`/post/fund/${id}/managers/delete`, { + id: user.id, + }); } catch (e) { fail(e.message); } @@ -25,14 +29,14 @@ Fund managers - {#each managers as c} + {#each m as c}

{c.username}

-
-- cgit v1.2.3 From fea147df07046f240e77075e7c743959d85b1271 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 19 Jul 2025 08:41:49 -0700 Subject: handle tipping for lnurls, sweep fixes --- .../fund/[id]/sweep/[...amount]/+page.server.ts | 11 ++++++--- .../(app)/fund/[id]/sweep/[...amount]/+page.svelte | 3 +-- src/routes/(app)/ln/[lnurl]/+page.server.ts | 28 ++++++++++++---------- 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 61a66fd2..8a8e71ee 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -8,8 +8,9 @@ export async function load({ cookies, request, params, parent }) { const { id } = params; let [amount, currency] = params.amount.split("/"); + if (!currency) currency = user?.currency; const rates = await getRates(); - const rate = rates[user?.currency || "USD"]; + const rate = rates[currency?.toUpperCase() || "USD"]; if (currency && !rate) error(500, "Invalid currency symbol"); if (!amount) { @@ -35,6 +36,10 @@ export async function load({ cookies, request, params, parent }) { await register(user, ip, cookies, `/fund/${id}/sweep`); } - await post("/take", { amount, id }, auth(cookies)); - return { amount, id, rate, rates, password }; + try { + await post("/take", { amount, id }, auth(cookies)); + } catch (e) { + redirect(307, `/fund/${id}`); + } + return { amount, currency, id, rate, rates, password }; } diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte index adba77ae..7a7d5402 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte @@ -11,8 +11,7 @@ let { data } = $props(); - let { amount, id, user, rate, rates, password: pw } = data; - let { currency } = user; + let { amount, currency, id, user, rate, rates, password: pw } = data; let locale = $derived(loc(user)); onMount(() => ($password = pw)); diff --git a/src/routes/(app)/ln/[lnurl]/+page.server.ts b/src/routes/(app)/ln/[lnurl]/+page.server.ts index 1ee182b1..b77a84e7 100644 --- a/src/routes/(app)/ln/[lnurl]/+page.server.ts +++ b/src/routes/(app)/ln/[lnurl]/+page.server.ts @@ -23,17 +23,17 @@ export async function load({ params, parent }) { } let { callback, minSendable, maxSendable, comment, tag } = data; - if (callback.includes(PUBLIC_DOMAIN)) { - const username = url.split(`https://${PUBLIC_DOMAIN}/p/`)[1]; - // const inv = await post("/invoice", { - // invoice: { type: types.lightning, amount: minSendable / 1000 }, - // user: { username }, - // }); - // const { id: iid } = inv; - let redir = `/pay/${username}`; - if (minSendable === maxSendable && minSendable > 0) redir += `/${minSendable / 1000}`; - redirect(307, redir); - } + // if (callback.includes(PUBLIC_DOMAIN)) { + // const username = url.split(`https://${PUBLIC_DOMAIN}/p/`)[1]; + // // const inv = await post("/invoice", { + // // invoice: { type: types.lightning, amount: minSendable / 1000 }, + // // user: { username }, + // // }); + // // const { id: iid } = inv; + // let redir = `/pay/${username}`; + // if (minSendable === maxSendable && minSendable > 0) redir += `/${minSendable / 1000}`; + // redirect(307, redir); + // } if (tag === "payRequest" && minSendable === maxSendable) { minSendable = Math.round(minSendable / 1000); maxSendable = Math.round(maxSendable / 1000); @@ -43,7 +43,10 @@ export async function load({ params, parent }) { if (comment) url += `&comment=${comment}`; const { pr } = await fetch(url).then((r) => (r as Response).json()); - console.log("PR", pr); + + const invoice = await get(`/invoice/${pr}`); + if (invoice) redirect(307, `/invoice/${invoice.id}`); + let path = `/send/lightning/${pr}`; if (comment) path += `/${encodeURIComponent(comment)}`; redirect(307, path); @@ -75,6 +78,7 @@ export const actions = { 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); -- cgit v1.2.3 From f24ec95a246ab38bb3253425fd8446dd93176fe9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 25 Jul 2025 19:35:17 -0700 Subject: authorizations --- src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 8a8e71ee..d0e49fcc 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -36,10 +36,13 @@ export async function load({ cookies, request, params, parent }) { await register(user, ip, cookies, `/fund/${id}/sweep`); } + let r; try { - await post("/take", { amount, id }, auth(cookies)); + r = await post("/take", { amount, id }, auth(cookies)); } catch (e) { redirect(307, `/fund/${id}`); } + + if (r) redirect(307, `/${user.username}`); return { amount, currency, id, rate, rates, password }; } -- cgit v1.2.3 From bf5ab3fdb6d6c1ffc1e1dc66b737d501e4fd710d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 25 Jul 2025 21:32:44 -0700 Subject: fix redirect url for fund sweeps --- src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index d0e49fcc..021015ee 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -33,7 +33,11 @@ export async function load({ cookies, request, params, parent }) { fresh: true, }; - await register(user, ip, cookies, `/fund/${id}/sweep`); + let redirectUrl = `/fund/${id}/sweep`; + if (amount) redirectUrl += `/${amount}`; + if (currency) redirectUrl += `/${currency}`; + + await register(user, ip, cookies, redirectUrl); } let r; -- cgit v1.2.3 From 222a134d33c7d44e9ae6ce34fdbbeb92ed1cfa8a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 25 Jul 2025 23:17:28 -0700 Subject: fund authorizations --- src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 021015ee..47dfdaab 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -20,7 +20,7 @@ export async function load({ cookies, request, params, parent }) { amount = (amount * sats) / rate; } - const username = randomName(); + const username = randomName() + Math.floor(Math.random() * 99) + 1; const password = randomPassword(); if (!amount) redirect(307, `/fund/${id}`); @@ -34,19 +34,17 @@ export async function load({ cookies, request, params, parent }) { }; let redirectUrl = `/fund/${id}/sweep`; - if (amount) redirectUrl += `/${amount}`; - if (currency) redirectUrl += `/${currency}`; + if (params.amount && !params.currency) redirectUrl += `/${params.amount}`; + if (params.currency) redirectUrl += `/${params.amount}/params.currency}`; await register(user, ip, cookies, redirectUrl); } - let r; try { - r = await post("/take", { amount, id }, auth(cookies)); + ({ amount } = await post("/take", { amount, id }, auth(cookies))); } catch (e) { redirect(307, `/fund/${id}`); } - if (r) redirect(307, `/${user.username}`); return { amount, currency, id, rate, rates, password }; } -- cgit v1.2.3 From 5757ef30eb664441e023396cae5a7f8b5db409ff Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 29 Jul 2025 13:36:05 -0700 Subject: detect fund updates --- src/routes/(app)/fund/[id]/access/+page.svelte | 1 + src/routes/(app)/payment/[id]/+page.svelte | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte index 23a829a9..cc2921c5 100644 --- a/src/routes/(app)/fund/[id]/access/+page.svelte +++ b/src/routes/(app)/fund/[id]/access/+page.svelte @@ -7,6 +7,7 @@ let { data } = $props(); let { id, managers } = $derived(data); let m = $state(data.managers); + $effect(() => (m = data.managers)); let username = $state(); let del = async (e, user) => { e.preventDefault(); diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index fcde487b..0667291e 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -67,7 +67,9 @@ let direction = $state(""); onMount(() => { - direction = amount > 0 ? $t("payments.from") : $t("payments.to"); + let a = amount; + if (type === types.fund) a = 0 - a; + direction = a > 0 ? $t("payments.from") : $t("payments.to"); if (direction) direction = -- cgit v1.2.3 From 633e3a3d94777440f07ed00a88abc1ac388bb2f0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 10 Aug 2025 18:53:09 -0700 Subject: authorizations --- .../[id]/authorize/[...amount]/+page.server.ts | 36 ++++++++++++++++++++++ .../fund/[id]/authorize/[...amount]/+page.svelte | 27 ++++++++++++++++ .../fund/[id]/sweep/[...amount]/+page.server.ts | 7 +++-- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts create mode 100644 src/routes/(app)/fund/[id]/authorize/[...amount]/+page.svelte (limited to 'src/routes/(app)/fund') diff --git a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts new file mode 100644 index 00000000..e5683ae6 --- /dev/null +++ b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts @@ -0,0 +1,36 @@ +import getRates from "$lib/rates"; +import { auth, get, post, sats } from "$lib/utils"; +import { error, redirect } from "@sveltejs/kit"; + +export async function load({ cookies, params, parent }) { + const { user } = await parent(); + const { id } = params; + let [amount, currency] = params.amount.split("/"); + let fiat; + + if (!currency) currency = user?.currency; + if (currency) currency = currency.toUpperCase(); + + const rates = await getRates(); + const rate = rates[currency || "USD"]; + if (currency && !rate) error(500, "Invalid currency symbol"); + + if (!amount) { + const balance = await get(`/fund/${id}`); + amount = balance.amount; + } else if (currency) { + fiat = amount; + amount = Math.round((fiat * sats) / rate); + } + + if (!amount) redirect(307, `/fund/${id}`); + + try { + await post("/authorize", { amount, currency, fiat, id }, auth(cookies)); + } catch (e) { + console.log("caught", e); + redirect(307, `/fund/${id}`); + } + + return { amount, currency, id, rate, rates }; +} diff --git a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.svelte b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.svelte new file mode 100644 index 00000000..b94c1ce9 --- /dev/null +++ b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.svelte @@ -0,0 +1,27 @@ + + +
+ +
+ +
+
+
+ +
+ {$t("payments.tapAnywhere")} +
diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 47dfdaab..78df3461 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -9,15 +9,16 @@ export async function load({ cookies, request, params, parent }) { let [amount, currency] = params.amount.split("/"); if (!currency) currency = user?.currency; + if (currency) currency = currency.toUpperCase(); const rates = await getRates(); - const rate = rates[currency?.toUpperCase() || "USD"]; + const rate = rates[currency || "USD"]; if (currency && !rate) error(500, "Invalid currency symbol"); if (!amount) { const balance = await get(`/fund/${id}`); - amount = balance.amount; + amount = balance.authorization || balance.amount; } else if (currency) { - amount = (amount * sats) / rate; + amount = Math.round((amount * sats) / rate); } const username = randomName() + Math.floor(Math.random() * 99) + 1; -- cgit v1.2.3 From c0ba00eae40dde1811fcb52099840b2b42120271 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 20 Aug 2025 13:42:50 -0700 Subject: numpad fixes --- src/components/Numpad.svelte | 67 +++++++++++++++++----- src/components/SetAmount.svelte | 10 ++-- src/routes/(app)/[username]/receive/+page.svelte | 2 +- src/routes/(app)/fund/[id]/withdraw/+page.svelte | 8 ++- .../(app)/send/bitcoin/[address]/+page.svelte | 5 +- .../[address]/[amount]/[...feeRate]/+page.svelte | 22 +++++-- .../send/fund/[...name]/[...amount]/+page.svelte | 5 +- 7 files changed, 88 insertions(+), 31 deletions(-) (limited to 'src/routes/(app)/fund') diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 00547e6a..8ebbfdf1 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -3,14 +3,15 @@ import Left from "$comp/Left.svelte"; import { f, s, focus, warning, sat, sats } from "$lib/utils"; import { t } from "$lib/translations"; + import { fiat as fiatStore } from "$lib/store"; // ---- Props (Svelte 5 runes) ---- let { - amount = $bindable(0), + amount = $bindable(), currency = "USD", - fiat = $bindable(true), + fiat = $bindable(), element, - rate, + rate = $bindable(), locale, submit = undefined, amountFiat = 0, @@ -217,12 +218,28 @@ sel.removeAllRanges(); sel.addRange(range); }); + + $fiatStore = fiat; }; const arrow = "<"; - const numPad = ["1","2","3","4","5","6","7","8","9","00","0",arrow]; + const numPad = [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "00", + "0", + arrow, + ]; onMount(() => { + fiat = $fiatStore; if (fiat) { const cents = Math.round((parseFloat(amountFiat || "0") || 0) * 100); fiatDigits = Math.max(0, cents).toString(); @@ -237,12 +254,18 @@
-
+
{#if fiat} {#if position === "before"}{symbol}{/if} {:else} - + {/if}
@@ -279,7 +302,11 @@ }} > {#if fiat} - + {s(amount, locale)} {:else} {f(amountFiat, currency, locale)} @@ -290,15 +317,29 @@
{#each numPad as value} {#if value === arrow} - {:else} - {/if} diff --git a/src/components/SetAmount.svelte b/src/components/SetAmount.svelte index a453b9d1..536c8e24 100644 --- a/src/components/SetAmount.svelte +++ b/src/components/SetAmount.svelte @@ -6,13 +6,13 @@ let submit = $state(); let { - currency = $bindable(), - fiat = $bindable(), - locale = $bindable(), - rate = $bindable(), + currency = $bindable("USD"), + fiat = $bindable(true), + locale = $bindable("en-US"), + rate = $bindable(0), settingAmount, setAmount, - newAmount = $bindable(), + newAmount = $bindable(0), toggleAmount, t, } = $props(); diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte index 9b7ffc00..cd692abf 100644 --- a/src/routes/(app)/[username]/receive/+page.svelte +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -99,7 +99,7 @@ await update(); }; - let newAmount = $state(); + let newAmount = $state(0); let settingAmount = $state(); let fiat = $state(true); let toggleAmount = () => (settingAmount = !settingAmount); diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte index 78f9b16c..69a74a3f 100644 --- a/src/routes/(app)/fund/[id]/withdraw/+page.svelte +++ b/src/routes/(app)/fund/[id]/withdraw/+page.svelte @@ -6,15 +6,17 @@ import Numpad from "$comp/Numpad.svelte"; import Spinner from "$comp/Spinner.svelte"; import { page } from "$app/stores"; - import { s } from "$lib/utils"; + import { loc, s } from "$lib/utils"; import { fiat, pin } from "$lib/store"; let { data, form } = $props(); - let { currency } = $derived(data.user); + let { user } = $derived(data); + let { currency } = $derived(user); let loading = $state(); let { id, balance, rate } = $derived(data); let { amount } = $state(data); + let locale = loc(user); let submit = $state(); let submitting = $state(); @@ -39,7 +41,7 @@ {/if}
- + diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/+page.svelte index 671de954..529e2691 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/+page.svelte @@ -5,13 +5,14 @@ import Numpad from "$comp/Numpad.svelte"; import { page } from "$app/stores"; import { rate } from "$lib/store"; - import { fail, s } from "$lib/utils"; + import { loc, fail, s } from "$lib/utils"; let { data } = $props(); let { balance, user } = data; let { address } = $page.params; let { currency, username } = user; + let locale = loc(user); let amount = $state(0); let a = $state(0); @@ -34,7 +35,7 @@
{address}
- +