aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-10 10:17:27 -0700
committerAdam Soltys <[email protected]>2024-09-10 10:17:27 -0700
commitbc94288f562223ca3bd0dd969c68c6650adf6089 (patch)
treed10682f94837199c39973951dea5d6e365f1d70f /routes/users.ts
parent9c77d45cfb56e79e97b70678e21b8d6a56ec6c78 (diff)
downloadcoinos-server-bc94288f562223ca3bd0dd969c68c6650adf6089.tar.gz
coinos-server-bc94288f562223ca3bd0dd969c68c6650adf6089.zip
accounts
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts17
1 files changed, 7 insertions, 10 deletions
diff --git a/routes/users.ts b/routes/users.ts
index f49ca212..a39bdbe3 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -13,8 +13,10 @@ import { types } from "$lib/payments";
import { bech32 } from "bech32";
import { mail, templates } from "$lib/mail";
import upload from "$lib/upload";
+import rpc from "@coinos/rpc";
-const { encode, decode, fromWords, toWords } = bech32;
+let bc = rpc(config.bitcoin);
+let { encode, decode, fromWords, toWords } = bech32;
export default {
upload,
@@ -567,15 +569,7 @@ export default {
async accounts(req, res) {
let { user } = req;
- let balance = await g(`balance:${user.id}`);
- let accounts: any = [
- {
- balance,
- type: "Cash",
- mint: "https://mint.coinos.io",
- },
- ];
-
+ let accounts = [];
for (let id of await db.lRange(`${user.id}:accounts`, 0, 1)) {
let account = await g(`account:${id}`);
account.balance = await g(`balance:${id}`);
@@ -612,8 +606,11 @@ export default {
let id = v4();
let account = { id, seed, type };
+ await bc.createWallet(id);
+
await s(`account:${id}`, account);
await s(`balance:${id}`, 0);
+ await s(`pending:${id}`, 0);
await db.lPush(`${user.id}:accounts`, id);
res.send(account);