From 0aea60330afff02ad8bb525c5fddd7c367abf03a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 4 Apr 2023 00:05:23 -0700 Subject: skip processed payments --- lib/payments.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/payments.js') 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, -- cgit v1.2.3