From 71fde8aa24b2e976b450fa16e3debe1078433086 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 26 Feb 2026 13:36:41 -0800 Subject: fix ark vault to custodial sends --- index.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'index.ts') 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; -- cgit v1.2.3