aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-08 13:46:09 -0800
committerAdam Soltys <[email protected]>2023-11-11 00:06:47 -0800
commitf0c9dd97783ae0cd8c726bd3c77725e978e7a8ec (patch)
treefe63a986e164ec71109b57aac72b91ce575dcad1
parent30910e1a7c02b7a4c18d029c521136c77e9ee8bc (diff)
downloadcoinos-server-f0c9dd97783ae0cd8c726bd3c77725e978e7a8ec.tar.gz
coinos-server-f0c9dd97783ae0cd8c726bd3c77725e978e7a8ec.zip
rename pot to fund
-rw-r--r--index.js4
-rw-r--r--lib/payments.js2
-rw-r--r--routes/payments.js34
3 files changed, 20 insertions, 20 deletions
diff --git a/index.js b/index.js
index b818188f..40c72795 100644
--- a/index.js
+++ b/index.js
@@ -53,8 +53,8 @@ app.post("/payments", auth, payments.create);
app.get("/payments", auth, payments.list);
app.get("/payments/:hash", auth, payments.get);
app.post("/parse", payments.parse);
-app.get("/pot/:name", payments.pot);
-app.get("/pot/:name/withdraw", payments.withdraw);
+app.get("/fund/:name", payments.fund);
+app.get("/fund/:name/withdraw", payments.withdraw);
app.post("/take", auth, payments.take);
app.post("/buy", auth, payments.buy);
app.post("/print", auth, payments.print);
diff --git a/lib/payments.js b/lib/payments.js
index cb9658af..e1ed5d0b 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -20,7 +20,7 @@ export const types = {
internal: "internal",
bitcoin: "bitcoin",
lightning: "lightning",
- pot: "pot",
+ fund: "fund",
classic: "classic"
};
diff --git a/routes/payments.js b/routes/payments.js
index 84edc786..49d3bdac 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -158,12 +158,12 @@ export default {
p = await debit(hash, amount, 0, memo, user);
await credit(hash, amount, memo, user.id);
} else {
- let pot = name || v4();
- memo = pot;
- p = await debit(hash, amount, 0, memo, user, types.pot);
- await db.incrBy(`pot:${pot}`, amount);
- await db.lPush(`pot:${pot}:payments`, p.id);
- l("funded pot", pot);
+ let fund = name || v4();
+ memo = fund;
+ p = await debit(hash, amount, 0, memo, user, types.fund);
+ await db.incrBy(`fund:${fund}`, amount);
+ await db.lPush(`fund:${fund}:payments`, p.id);
+ l("funded fund", fund);
}
}
@@ -248,11 +248,11 @@ export default {
}
},
- async pot({ params: { name } }, res) {
- let amount = await g(`pot:${name}`);
+ async fund({ params: { name } }, res) {
+ let amount = await g(`fund:${name}`);
if (typeof amount === "undefined" || amount === null)
- return bail(res, "pot not found");
- let payments = (await db.lRange(`pot:${name}:payments`, 0, -1)) || [];
+ return bail(res, "fund not found");
+ let payments = (await db.lRange(`fund:${name}:payments`, 0, -1)) || [];
payments = await Promise.all(payments.map(hash => g(`payment:${hash}`)));
await Promise.all(
@@ -264,12 +264,12 @@ export default {
},
async withdraw({ params: { name } }, res) {
- let maxWithdrawable = await g(`pot:${name}`);
+ let maxWithdrawable = await g(`fund:${name}`);
res.send({
tag: "withdrawRequest",
callback: `${URL}/lnurlw/${name}`,
k1: name,
- defaultDescription: `Withdraw from coinos pot ${name}`,
+ defaultDescription: `Withdraw from coinos fund ${name}`,
minWithdrawable: 0,
maxWithdrawable
});
@@ -280,11 +280,11 @@ export default {
amount = parseInt(amount);
if (amount < 0) fail("Invalid amount");
- await t(`pot:${name}`, async (balance, db) => {
+ await t(`fund:${name}`, async (balance, db) => {
if (balance < amount) fail("Insufficient funds");
await db
.multi()
- .decrBy(`pot:${name}`, amount)
+ .decrBy(`fund:${name}`, amount)
.exec();
});
@@ -301,12 +301,12 @@ export default {
});
}
- let payment = await credit(id, amount, name, name, types.pot);
- await db.lPush(`pot:${name}:payments`, payment.id);
+ let payment = await credit(id, amount, name, name, types.fund);
+ await db.lPush(`fund:${name}:payments`, payment.id);
res.send({ payment });
} catch (e) {
- warn("problem withdrawing from pot", e.message);
+ warn("problem withdrawing from fund", e.message);
bail(res, e.message);
}
},