aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-05-04 10:05:51 -0700
committerAdam Soltys <[email protected]>2023-05-04 10:05:56 -0700
commit88990faa498ab269d1745dc6524cddf2fe9e5245 (patch)
treed6bbad89b7d1dae165e8cd863cc74406a44223bc
parentf695cbd6d1ed9d8560363693c0f3bdcb7c78c7d8 (diff)
downloadcoinos-server-88990faa498ab269d1745dc6524cddf2fe9e5245.tar.gz
coinos-server-88990faa498ab269d1745dc6524cddf2fe9e5245.zip
set rate for pot invoices
-rw-r--r--lib/payments.js1
-rw-r--r--routes/payments.js4
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/payments.js b/lib/payments.js
index 7dbc1775..e1e0590e 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -122,6 +122,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
let equivalentRate =
invoice.rate * (store.rates[currency] / store.rates[invoice.currency]);
+
if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) {
rate = equivalentRate;
} else {
diff --git a/routes/payments.js b/routes/payments.js
index cb942940..282a8682 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -111,6 +111,7 @@ export default {
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);
@@ -202,7 +203,10 @@ export default {
});
let hash = v4();
+ let { currency } = user;
await s(`invoice:${hash}`, {
+ currency,
+ rate: store.rates[currency],
uid: user.id,
received: 0
});