aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-02 23:30:00 -0800
committerAdam Soltys <[email protected]>2026-02-06 08:58:12 -0800
commit4850177f50b7ff5a0f37acaa92190219d6f72da5 (patch)
tree37610dc2c6d5838fbd627d46f1c5bb6d5de9c134
parent1d3bf713e874e3ce0e5efe9f0dff459d5c1471ca (diff)
downloadcoinos-server-4850177f50b7ff5a0f37acaa92190219d6f72da5.tar.gz
coinos-server-4850177f50b7ff5a0f37acaa92190219d6f72da5.zip
ark sync
-rw-r--r--index.ts1
-rw-r--r--routes/payments.ts62
-rw-r--r--wallet.Dockerfile4
3 files changed, 64 insertions, 3 deletions
diff --git a/index.ts b/index.ts
index faab936d..a5e60310 100644
--- a/index.ts
+++ b/index.ts
@@ -90,6 +90,7 @@ app.post("/replace", auth, payments.replace);
app.get("/decode/:bolt11", payments.decode);
app.post("/fetchinvoice", payments.fetchinvoice);
app.post("/ark/receive", auth, payments.arkReceive);
+app.post("/ark/sync", auth, payments.arkSync);
app.get("/square/connect", auth, square.connect);
app.get("/square/auth", auth, square.auth);
diff --git a/routes/payments.ts b/routes/payments.ts
index cfbae56b..752c7ce8 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -769,13 +769,22 @@ export default {
created: Date.now(),
};
+ const { id: uid } = user;
+ await s(`payment:${hash}`, p.id);
+ await s(`payment:${p.id}`, p);
+ await db
+ .multi()
+ .lPush(`${aid || uid}:payments`, p.id)
+ .set(`${aid || uid}:payments:last`, p.created)
+ .exec();
+
res.send(p);
},
async arkReceive(req, res) {
try {
const { body, user } = req;
- const { iid, amount } = body;
+ const { iid, amount, hash } = body;
const { id: uid } = user;
if (amount <= 0) fail("Invalid amount");
@@ -816,4 +825,55 @@ export default {
bail(res, e.message);
}
},
+
+ async arkSync(req, res) {
+ try {
+ const { user } = req;
+ const { transactions, aid } = req.body;
+ const { id: uid, currency } = user;
+
+ const rates = await g("rates");
+ const rate = rates[currency];
+
+ let synced = 0;
+ for (const tx of transactions) {
+ const existingId = await g(`payment:${tx.hash}`);
+ if (existingId) {
+ const existing = await g(`payment:${existingId}`);
+ if (existing && !existing.confirmed && tx.settled) {
+ existing.confirmed = true;
+ await s(`payment:${existingId}`, existing);
+ }
+ continue;
+ }
+
+ const p = {
+ id: v4(),
+ aid,
+ amount: tx.amount,
+ hash: tx.hash,
+ confirmed: tx.settled,
+ rate,
+ currency,
+ type: PaymentType.ark,
+ uid,
+ created: tx.createdAt,
+ };
+
+ await s(`payment:${tx.hash}`, p.id);
+ await s(`payment:${p.id}`, p);
+ await db
+ .multi()
+ .lPush(`${aid || uid}:payments`, p.id)
+ .set(`${aid || uid}:payments:last`, p.created)
+ .exec();
+
+ synced++;
+ }
+
+ res.send({ synced });
+ } catch (e) {
+ bail(res, e.message);
+ }
+ },
};
diff --git a/wallet.Dockerfile b/wallet.Dockerfile
index db080737..8c1d48fd 100644
--- a/wallet.Dockerfile
+++ b/wallet.Dockerfile
@@ -1,11 +1,11 @@
# First stage: build the ark-wallet-daemon binary
-FROM golang:1.25.3 AS builder
+FROM golang:1.25.6 AS builder
ARG VERSION
ARG TARGETOS
ARG TARGETARCH
-ARG BRANCH=v0.8.4
+ARG BRANCH=master
WORKDIR /app