aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/ecash.ts4
-rw-r--r--routes/invoices.ts12
2 files changed, 10 insertions, 6 deletions
diff --git a/routes/ecash.ts b/routes/ecash.ts
index e4898358..25b7a255 100644
--- a/routes/ecash.ts
+++ b/routes/ecash.ts
@@ -3,7 +3,7 @@ import { check, claim, get, mint } from "$lib/ecash";
import { err, l } from "$lib/logging";
import { credit, debit } from "$lib/payments";
import { emit } from "$lib/sockets";
-import { bail, fail } from "$lib/utils";
+import { bail, fail, getInvoice } from "$lib/utils";
import { getEncodedToken } from "@cashu/cashu-ts";
import { v4 } from "uuid";
@@ -147,7 +147,7 @@ export default {
async receive(req, res) {
try {
const { id, proofs, mint, memo } = req.body;
- const { uid: ref } = await g(`invoice:${id}`);
+ const { uid: ref } = await getInvoice(id);
const amount = await claim(
getEncodedToken({
diff --git a/routes/invoices.ts b/routes/invoices.ts
index 8b71208d..0881c69f 100644
--- a/routes/invoices.ts
+++ b/routes/invoices.ts
@@ -1,5 +1,5 @@
import config from "$config";
-import { db, g } from "$lib/db";
+import { db } from "$lib/db";
import { generate } from "$lib/invoices";
import { err } from "$lib/logging";
import { bail, fields, getInvoice, getUser } from "$lib/utils";
@@ -10,8 +10,7 @@ export default {
const {
params: { id },
} = req;
- let invoice = await g(`invoice:${id}`);
- if (typeof invoice === "string") invoice = await g(`invoice:${invoice}`);
+ const invoice = await getInvoice(id);
if (invoice) {
invoice.secret = undefined;
@@ -31,7 +30,12 @@ export default {
try {
res.send(await generate({ invoice, user }));
} catch (e) {
- err("problem generating invoice", req.user?.username, body.user?.username, e.message);
+ err(
+ "problem generating invoice",
+ req.user?.username,
+ body.user?.username,
+ e.message,
+ );
bail(res, e.message);
}
},