aboutsummaryrefslogtreecommitdiffstats
path: root/index.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-26 13:36:41 -0800
committerAdam Soltys <[email protected]>2026-02-26 13:36:41 -0800
commit71fde8aa24b2e976b450fa16e3debe1078433086 (patch)
treeaef96c21488aa36412aac67d1135594cc83c5372 /index.ts
parentf031bed801d858b006cb8a49131e18851e10bbec (diff)
downloadcoinos-server-71fde8aa24b2e976b450fa16e3debe1078433086.tar.gz
coinos-server-71fde8aa24b2e976b450fa16e3debe1078433086.zip
fix ark vault to custodial sends
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/index.ts b/index.ts
index ab20e388..efcaf484 100644
--- a/index.ts
+++ b/index.ts
@@ -1,5 +1,8 @@
+import config from "$config";
import app from "$lib/app";
+import { sendArk } from "$lib/ark";
import { admin, auth, optional } from "$lib/auth";
+import { g, s } from "$lib/db";
import { fixBolt12, listenForLightning, replay } from "$lib/lightning";
import { startHealthCheck } from "$lib/health";
@@ -224,6 +227,30 @@ app.post("/echo", (req, res) => {
res.send(req.body);
});
+app.post("/test/ark/send", async (req, res) => {
+ try {
+ const secret = req.headers["x-test-secret"] as string;
+ if (!config.testSecret || secret !== config.testSecret) {
+ return res.code(403).send("Forbidden");
+ }
+ const { address, amount, iid } = req.body;
+ const txid = await sendArk(address, amount);
+
+ // Mark invoice as paid so tests don't need client-side SDK sync
+ if (iid) {
+ const invoice = await g(`invoice:${iid}`);
+ if (invoice) {
+ invoice.received = (invoice.received || 0) + amount;
+ await s(`invoice:${iid}`, invoice);
+ }
+ }
+
+ res.send({ txid, iid });
+ } catch (e: any) {
+ res.code(500).send(e.message);
+ }
+});
+
const host: string = process.env["HOST"] || "0.0.0.0";
const port: number = Number.parseInt(process.env["PORT"]) || 3119;