diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/payments.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/payments.js b/lib/payments.js index b1e57d9c..a48a187b 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -13,7 +13,7 @@ export const types = { bitcoin: "bitcoin", lightning: "lightning", pot: "pot", - classic: "classic", + classic: "classic" }; export let debit = async ( @@ -33,7 +33,12 @@ export let debit = async ( let invoice = await g(`invoice:${hash}`); if (invoice) { ref = invoice.uid; - if (Math.abs(invoice.rate / rate - 1) < 0.01) rate = invoice.rate; + if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) { + rate = + invoice.rate * (store.rates[currency] / store.rates[invoice.currency]); + } else { + warn("rate slipped", hash, invoice.rate, equivalentRate); + } } let tip = parseInt(invoice?.tip) || null; @@ -81,7 +86,7 @@ export let debit = async ( type, ref, tip, - created: Date.now(), + created: Date.now() }; await s(`payment:${id}`, p); @@ -120,7 +125,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { tip, type, confirmed: true, - created: Date.now(), + created: Date.now() }; invoice.received += amount; |
