aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-16 23:16:58 -0700
committerAdam Soltys <[email protected]>2024-09-16 23:16:58 -0700
commitf1cd8904fb7231d43f16b7bc27f45b8b31a03fde (patch)
tree5243a0c70dc65e1d36957b41feaa41e6f4352f27 /routes
parent50cd51473f8cecc8b6893d9dff3142ca13b249e5 (diff)
downloadcoinos-server-f1cd8904fb7231d43f16b7bc27f45b8b31a03fde.tar.gz
coinos-server-f1cd8904fb7231d43f16b7bc27f45b8b31a03fde.zip
internal payments
Diffstat (limited to 'routes')
-rw-r--r--routes/payments.ts19
1 files changed, 4 insertions, 15 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index dbf5a8fd..2046cfb4 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -1,10 +1,9 @@
import config from "$config";
import { emit } from "$lib/sockets";
-import { generate } from "$lib/invoices";
import { v4 } from "uuid";
import { db, g, s, t } from "$lib/db";
import { l, err, warn } from "$lib/logging";
-import { bail, fail, getInvoice, sats, SATS, getUser } from "$lib/utils";
+import { bail, fail, getInvoice, getUser, sats, SATS } from "$lib/utils";
import { requirePin } from "$lib/auth";
import {
completePayment,
@@ -13,6 +12,7 @@ import {
credit,
types,
build,
+ sendInternal,
sendLightning,
sendOnchain,
} from "$lib/payments";
@@ -505,19 +505,8 @@ export default {
body: { username, amount },
user: sender,
} = req;
- let recipient = await getUser(username);
- let inv = await generate({
- invoice: { amount, type: "lightning" },
- user: recipient,
- sender,
- });
-
- let { hash } = inv;
- let memo;
- let p = await debit({ hash, amount, memo, user: sender });
- await credit({ hash, amount, memo, ref: recipient.id });
-
- res.send(p);
+ let recipient = await getUser(username);
+ res.send(await sendInternal({ amount, sender, recipient }));
},
};