aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-06 02:58:18 -0700
committerAdam Soltys <[email protected]>2022-10-06 02:58:18 -0700
commit28179d6b58df35bc31c72463cbd029db9d162baf (patch)
tree67a286c993860a59ba9580a89402b1383ef6957b
parent12fcb358b14e0754457d79e9103e46c6426218a8 (diff)
downloadcoinos-server-28179d6b58df35bc31c72463cbd029db9d162baf.tar.gz
coinos-server-28179d6b58df35bc31c72463cbd029db9d162baf.zip
handle invoice lookup by uuid
-rw-r--r--lib/sendInternal.js6
-rw-r--r--routes/invoices.js13
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/sendInternal.js b/lib/sendInternal.js
index 554dde91..ce131522 100644
--- a/lib/sendInternal.js
+++ b/lib/sendInternal.js
@@ -105,6 +105,7 @@ export default async (
if (address) params.where.address = address;
else if (payreq) params.where.text = payreq;
let invoice = (address || payreq) && (await db.Invoice.findOne(params));
+ console.log("HMM", address, payreq, invoice);
let a2;
let acc = {
@@ -157,14 +158,11 @@ export default async (
a2 = await db.Account.create(acc, { transaction });
}
- let spread = user.username === "coinos" ? 1.02 : 1;
- amount = Math.round(amount / spread);
-
params = {
amount,
account_id: a2.id,
user_id: recipient.id,
- rate: store.rates[recipient.currency] * spread,
+ rate: store.rates[recipient.currency],
currency: recipient.currency,
confirmed: true,
hash: `#${v4().substr(0, 6)} Payment from ${user.username}`,
diff --git a/routes/invoices.js b/routes/invoices.js
index f843d663..14efdf2a 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -32,10 +32,17 @@ app.get("/invoice", async (req, res, next) => {
app.get("/invoice/:text", async (req, res, next) => {
try {
let { text } = req.params;
+ let where =
+ text.split("-").length > 4
+ ? { uuid: text }
+ : text.startsWith("ln")
+ ? { text }
+ : {
+ [Op.or]: [{ unconfidential: text }, { address: text }]
+ };
+
const invoice = await db.Invoice.findOne({
- where: {
- [Op.or]: [{ unconfidential: text }, { address: text }, { text }]
- },
+ where,
include: {
model: db.User,
as: "user",