aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-06 16:55:45 +0000
committerAdam Soltys <[email protected]>2026-02-06 16:55:45 +0000
commit9089698e8df9d0c09c165c45eb6b05335a818699 (patch)
tree592be0e8964857d7be5ca9baacb6143b29903b27 /lib/payments.ts
parent0ad6c9ec8a4f91e1d45af4a76330cc3ddcf177a2 (diff)
downloadcoinos-server-9089698e8df9d0c09c165c45eb6b05335a818699.tar.gz
coinos-server-9089698e8df9d0c09c165c45eb6b05335a818699.zip
health check
Diffstat (limited to 'lib/payments.ts')
-rw-r--r--lib/payments.ts59
1 files changed, 0 insertions, 59 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index 80aee8b7..b0140f52 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -772,65 +772,6 @@ export const catchUp = async () => {
setTimeout(catchUp, 10000);
};
-export const reconcile = async (account, initial = false) => {
- try {
- const { descriptors, id, uid, type } = account;
- const user = await getUser(uid);
- const node = rpc({ ...config[type], wallet: id });
-
- let total;
-
- if (initial) {
- const progress = await node.scanTxOutSet("status");
- if (progress) return setTimeout(() => reconcile(account, initial), 1000);
-
- const { total_amount } = await node.scanTxOutSet("start", descriptors);
- total = Math.round(total_amount * SATS);
- } else {
- total = Math.round((await node.getBalance({ minconf: 1 })) * SATS);
- }
-
- const { balanceAdjustment: memo } = t(user);
-
- const balance = await g(`balance:${id}`);
-
- const amount = Math.abs(total - balance);
- const hash = v4();
-
- if (total > balance) {
- const inv = {
- memo,
- type: PaymentType.reconcile,
- hash,
- amount,
- uid,
- aid: id,
- };
- await s(`invoice:${hash}`, inv);
- await credit({
- hash,
- amount,
- type: PaymentType.reconcile,
- aid: id,
- });
- } else if (total < balance) {
- await debit({
- aid: id,
- amount,
- hash: v4(),
- memo,
- user,
- type: PaymentType.reconcile,
- });
- }
- } catch (e) {
- console.log(e);
- warn("problem reconciling", e.message, account);
- if (e.message.includes("progress"))
- return setTimeout(() => reconcile(account, initial), 1000);
- }
-};
-
export const check = async () => {
if (process.env.URL.includes("dev")) return;
try {