aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-13 14:14:02 -0800
committerAdam Soltys <[email protected]>2026-02-13 14:14:02 -0800
commit542cf1d084d189bcdf127c9c2359cced5267295e (patch)
treed9774ea67ae174b83a6e654eced1c10c9e3559a7 /routes
parent6de76d3a76f8b91b0ffa88bf175bb821234e84bd (diff)
downloadcoinos-server-542cf1d084d189bcdf127c9c2359cced5267295e.tar.gz
coinos-server-542cf1d084d189bcdf127c9c2359cced5267295e.zip
fix onchain confirmations
Diffstat (limited to 'routes')
-rw-r--r--routes/payments.ts37
1 files changed, 8 insertions, 29 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index 4377a15d..52e9057e 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -458,39 +458,22 @@ export default {
body: { txid, wallet, type },
} = req;
+ if (type !== PaymentType.liquid) return res.send({});
+
try {
const node = rpc({ ...config[type], wallet });
const { confirmations, details } = await node.getTransaction(txid);
- const hot = wallet === config[type].wallet;
- let aid;
- if (!hot) aid = wallet;
for (const { address, amount, asset, category, vout } of details) {
if (!address) continue;
- if (type === PaymentType.liquid && asset !== config.liquid.btc)
- continue;
-
- if (category === "send") {
- const p = await getPayment(txid);
- if (!p) continue;
+ if (asset !== config.liquid.btc) continue;
- if (confirmations) {
- p.confirmed = true;
- await s(`payment:${p.id}`, p);
- if (aid) await db.sRem(`inflight:${aid}`, p.id);
- } else {
- if (aid) await db.sAdd(`inflight:${aid}`, p.id);
- }
-
- emit(p.uid, "payment", p);
- continue;
- }
+ if (category === "send") continue;
const p = await getPayment(`${txid}:${vout}`);
if (!p) {
const invoice = await getInvoice(address);
- if (!hot && aid !== invoice?.aid) continue;
if (sats(amount) < 300) continue;
const lockKey = `lock:${txid}:${vout}`;
@@ -503,28 +486,24 @@ export default {
amount: sats(amount),
ref: `${txid}:${vout}`,
type,
- aid,
});
} else if (confirmations >= 1) {
- const id = `payment:${txid}:${vout}`;
- const p = await getPayment(`${txid}:${vout}`);
- if (!p) return db.sAdd("missed", id);
- if (p.confirmed) return;
+ if (p.confirmed) continue;
const invoice = await getInvoice(address);
- const { id: iid } = invoice;
+ if (!invoice) continue;
p.confirmed = true;
invoice.received += Number.parseInt(invoice.pending);
invoice.pending = 0;
- l("confirming", id, p.id, p.amount);
+ l("confirming", p.id, p.amount);
await tbConfirm(p.aid || p.uid, p.amount);
await db
.multi()
- .set(`invoice:${iid}`, JSON.stringify(invoice))
+ .set(`invoice:${invoice.id}`, JSON.stringify(invoice))
.set(`payment:${p.id}`, JSON.stringify(p))
.exec();