aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-04-04 00:05:23 -0700
committerAdam Soltys <[email protected]>2023-04-04 00:05:23 -0700
commit0aea60330afff02ad8bb525c5fddd7c367abf03a (patch)
tree52e0ce713368f5ab0f4d40c37f5194dcd55ae1f2 /lib/payments.js
parent44c59b03f100792708425bbcd806422fa921f1c5 (diff)
downloadcoinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.tar.gz
coinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.zip
skip processed payments
Diffstat (limited to 'lib/payments.js')
-rw-r--r--lib/payments.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/payments.js b/lib/payments.js
index 6e2e3a99..5dc24c9b 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -115,7 +115,15 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
let { id: uid, currency, username } = user;
let rate = store.rates[currency];
- if (Math.abs(invoice.rate / rate - 1) < 0.01) rate = invoice.rate;
+
+ 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 {
+ warn("rate slipped", hash, invoice.rate, equivalentRate);
+ }
let p = {
hash,