aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-08-06 20:15:21 -0700
committerAdam Soltys <[email protected]>2020-08-06 20:15:21 -0700
commit2a960a2448c3b936599a933b63a92af5d67273de (patch)
tree20b390a8776abb3446cc85017f2e8e2bc1c1d422
parent40fc89ab9b00da0d5928e663c7fde0717b2a96af (diff)
downloadcoinos-server-2a960a2448c3b936599a933b63a92af5d67273de.tar.gz
coinos-server-2a960a2448c3b936599a933b63a92af5d67273de.zip
user exists endpoint
-rw-r--r--lib/binance.js1
-rw-r--r--routes/bitcoin/fee.js17
-rw-r--r--routes/liquid/fee.js15
-rw-r--r--routes/send.js2
-rw-r--r--routes/users.js8
5 files changed, 32 insertions, 11 deletions
diff --git a/lib/binance.js b/lib/binance.js
index 55b29ee8..db45ff6c 100644
--- a/lib/binance.js
+++ b/lib/binance.js
@@ -18,7 +18,6 @@ module.exports = () => {
app.set("ask", msg.a);
app.set("bid", msg.b);
app.set("last", msg.c);
- app.set("balance", await lq.getBalance());
app.set("rates", rates);
checkQueue();
} catch (e) {
diff --git a/routes/bitcoin/fee.js b/routes/bitcoin/fee.js
index 220fbae9..da0fb9e9 100644
--- a/routes/bitcoin/fee.js
+++ b/routes/bitcoin/fee.js
@@ -3,12 +3,19 @@ module.exports = ah(async (req, res) => {
let { address, amount, feeRate } = req.body;
let tx, fee;
- let recipient = await db.User.findOne({
- attributes: ['username'],
- where: { address }
+ let invoice = await db.Invoice.findOne({
+ where: { address },
+ include: {
+ attributes: ['username'],
+ model: db.User,
+ as: 'user',
+ }
});
- if (recipient)
- emit(user.username, "to", recipient);
+
+ if (invoice) {
+ emit(user.username, "to", invoice.user);
+ return res.end();
+ }
try {
amount = parseInt(amount);
diff --git a/routes/liquid/fee.js b/routes/liquid/fee.js
index b68c4178..77a9ce17 100644
--- a/routes/liquid/fee.js
+++ b/routes/liquid/fee.js
@@ -3,12 +3,19 @@ module.exports = ah(async (req, res) => {
let { address, asset, amount, feeRate } = req.body;
let tx, fee;
- let recipient = await db.User.findOne({
- attributes: ["username"],
- where: { confidential: address },
+ let invoice = await db.Invoice.findOne({
+ where: { address },
+ include: {
+ attributes: ['username'],
+ model: db.User,
+ as: 'user',
+ }
});
- if (recipient) emit(user.username, "to", recipient);
+ if (invoice) {
+ emit(user.username, "to", invoice.user);
+ return res.end();
+ }
try {
if (config.liquid.walletpass)
diff --git a/routes/send.js b/routes/send.js
index 3e1ec208..405c0d95 100644
--- a/routes/send.js
+++ b/routes/send.js
@@ -133,7 +133,7 @@ module.exports = ah(async (req, res, next) => {
emit(user.username, "payment", payment);
l.info("received internal", user.username, amount);
- notify(user, `Received ${amount} SAT`);
+ notify(user, `Received ${amount} ${account.ticker} sats`);
}
});
} catch (e) {
diff --git a/routes/users.js b/routes/users.js
index 5331beab..75817753 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -116,6 +116,14 @@ app.post(
})
);
+app.get("/exists", ah(async (req, res) => {
+ let exists = await db.User.findOne({
+ where: { username: req.query.username },
+ });
+
+ res.send(!!exists);
+}));
+
app.post(
"/user",
auth,