aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-03 23:02:57 -0800
committerAdam Soltys <[email protected]>2026-03-03 23:02:57 -0800
commit63fad61716c013b6663df789ed96f6e294630642 (patch)
tree94b26a7df691d857c5648824699565f8f7340e52 /routes/users.ts
parent55ae58daf23028fa0f647f7bb2b4b0f8cd751de7 (diff)
downloadcoinos-server-63fad61716c013b6663df789ed96f6e294630642.tar.gz
coinos-server-63fad61716c013b6663df789ed96f6e294630642.zip
vault wallet fixes
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/routes/users.ts b/routes/users.ts
index 027d836e..78fddbc9 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -899,15 +899,18 @@ export default {
const paymentKeys = paymentIds.map((pid) => `payment:${pid}`);
const payments = await gfAll(paymentKeys);
let sum = 0;
+ let pending = 0;
for (const pay of payments) {
- if (pay) sum += pay.amount;
+ if (!pay) continue;
+ if (pay.confirmed === false) pending += pay.amount;
+ else sum += pay.amount - (pay.fee || 0);
}
account.balance = Math.max(sum, 0);
+ account.pending = Math.max(pending, 0);
} else {
account.balance = await getBalance(aid);
+ account.pending = await getPending(aid);
}
-
- account.pending = await getPending(aid);
accounts.push(account);
}
@@ -943,6 +946,16 @@ export default {
await createBalanceAccount(id);
+ if (pubkey && type === "bitcoin") {
+ const accountIds = await db.lRange(`${uid}:accounts`, 0, -1);
+ for (const accId of accountIds) {
+ const acc = await g(`account:${accId}`);
+ if (acc?.pubkey === pubkey) {
+ return bail(c, "A vault with this key already exists");
+ }
+ }
+ }
+
if (type === "ark") {
const accountIds = await db.lRange(`${user.id}:accounts`, 0, -1);
for (const accId of accountIds) {