diff options
| author | Adam Soltys <[email protected]> | 2023-04-04 00:05:23 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-04-04 00:05:23 -0700 |
| commit | 0aea60330afff02ad8bb525c5fddd7c367abf03a (patch) | |
| tree | 52e0ce713368f5ab0f4d40c37f5194dcd55ae1f2 /lib/payments.js | |
| parent | 44c59b03f100792708425bbcd806422fa921f1c5 (diff) | |
| download | coinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.tar.gz coinos-server-0aea60330afff02ad8bb525c5fddd7c367abf03a.zip | |
skip processed payments
Diffstat (limited to 'lib/payments.js')
| -rw-r--r-- | lib/payments.js | 10 |
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, |
