aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.ts2
-rw-r--r--lib/migrate.ts2
-rw-r--r--lib/utils.ts2
-rw-r--r--routes/users.ts21
4 files changed, 25 insertions, 2 deletions
diff --git a/index.ts b/index.ts
index c654f4f2..c9a6f90c 100644
--- a/index.ts
+++ b/index.ts
@@ -80,8 +80,10 @@ app.post("/bitcoin/fee", auth, payments.fee);
app.post("/bitcoin/send", auth, payments.send);
app.get("/account/:id", auth, users.account);
+app.post("/account/:id", auth, users.updateAccount);
app.get("/accounts", auth, users.accounts);
app.post("/accounts", auth, users.createAccount);
+app.post("/account/delete", auth, users.deleteAccount);
app.get("/users", auth, users.list);
app.get("/me", auth, users.me);
diff --git a/lib/migrate.ts b/lib/migrate.ts
index 203444bf..a289dee2 100644
--- a/lib/migrate.ts
+++ b/lib/migrate.ts
@@ -21,7 +21,7 @@ async function migrate(id) {
let accounts = await db.lLen(`${user.id}:accounts`);
if (!accounts) {
- await db.set(`account:${user.id}`, JSON.stringify({ id: user.id }));
+ await db.set(`account:${user.id}`, JSON.stringify({ id: user.id, name: "Cash" }));
await db.lPush(`${user.id}:accounts`, user.id);
}
return user;
diff --git a/lib/utils.ts b/lib/utils.ts
index 2eab7f67..388ee6c8 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -38,7 +38,7 @@ export let bip21 = (address, { amount, memo, tip, type }) => {
let url = new URLSearchParams();
if (amount) {
- url.append("amount", btc(amount + tip));
+ url.append("amount", btc(amount + tip).toFixed(8));
if (type === "liquid") url.append("assetid", config.liquid.btc);
}
diff --git a/routes/users.ts b/routes/users.ts
index 25a08ba1..6550d90f 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -655,4 +655,25 @@ export default {
bail(res, e.message);
}
},
+
+ async updateAccount(req, res) {
+ let { id } = req.params;
+ let { name } = req.body;
+
+ let account = await g(`account:${id}`);
+ account.name = name;
+ await s(`account:${id}`, account);
+
+ res.send(account);
+ },
+
+ async deleteAccount(req, res) {
+ let { id } = req.body;
+ let { id: uid } = req.user;
+
+ await db.lRem(`${uid}:accounts`, 1, id);
+ await db.del(`account:${id}`);
+
+ res.send({ ok: true });
+ },
};