aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/parse.ts6
-rw-r--r--src/routes/(app)/ecash/[id]/[...version]/+layout.server.ts13
2 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/parse.ts b/src/lib/parse.ts
index 663b2e42..e8d8bafd 100644
--- a/src/lib/parse.ts
+++ b/src/lib/parse.ts
@@ -105,10 +105,8 @@ export default async (s, host, cookies) => {
.join("");
}
- if (t.startsWith("cashu")) {
- const { id } = await post("/cash", { token: t });
- redirect(307, `/ecash/${id}`);
- }
+ // The token rides in the URL; the ecash page asks the server for its status.
+ if (t.startsWith("cashu")) redirect(307, `/ecash/${encodeURIComponent(t)}`);
if (t.startsWith("creq")) redirect(307, `/send/ecash/${t}`);
diff --git a/src/routes/(app)/ecash/[id]/[...version]/+layout.server.ts b/src/routes/(app)/ecash/[id]/[...version]/+layout.server.ts
index 50be6986..e241930e 100644
--- a/src/routes/(app)/ecash/[id]/[...version]/+layout.server.ts
+++ b/src/routes/(app)/ecash/[id]/[...version]/+layout.server.ts
@@ -1,5 +1,5 @@
import getRates from "$lib/rates";
-import { get } from "$lib/utils";
+import { get, post } from "$lib/utils";
export async function load({ params, parent }) {
const { user } = await parent();
@@ -8,7 +8,16 @@ export async function load({ params, parent }) {
version ||= 4;
version = parseInt(version);
- const { token, status } = await get(`/cash/${id}/${version}`);
+ // A pasted token arrives in the URL itself and is checked statelessly;
+ // anything else is an id from the share links the server used to hand out.
+ let token: string;
+ let status: any;
+ if (id.startsWith("cashu")) {
+ token = id;
+ status = await post("/ecash/status", { token });
+ } else {
+ ({ token, status } = await get(`/cash/${id}/${version}`));
+ }
const { spent, total, mint, external } = status;
return {
id,