diff options
| author | Adam Soltys <[email protected]> | 2024-01-24 04:47:08 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-01-24 04:47:08 +0000 |
| commit | 56d32950584c88d11c3eeaa1d08f46fee99134ba (patch) | |
| tree | c714a739f9ceab8c8ec48066649a34f173148112 | |
| parent | 712560b83d8834145b974f2324b0deb5c18b91b8 (diff) | |
| download | coinos-server-56d32950584c88d11c3eeaa1d08f46fee99134ba.tar.gz coinos-server-56d32950584c88d11c3eeaa1d08f46fee99134ba.zip | |
handle null ourfee value
| -rw-r--r-- | lib/db.js | 2 | ||||
| -rw-r--r-- | lib/payments.js | 7 |
2 files changed, 5 insertions, 4 deletions
@@ -90,7 +90,7 @@ export let g = async (k) => { }; export let s = (k, v) => { - if (k === "user:null" || k === "user:undefined") fail("null user"); + if (k === "user:null" || k === "user:undefined") fail("null user"); db.set(k, JSON.stringify(v)); }; diff --git a/lib/payments.js b/lib/payments.js index 550e3791..8965b530 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -270,9 +270,10 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => { if (recordExists && paymentFailed) { await db.del(`payment:${p.id}`); - let credit = Math.round(total * config.fee) - p.ourfee; - warn("crediting balance", total + maxfee + p.ourfee); - await db.incrBy(`balance:${p.uid}`, total + maxfee + p.ourfee); + let ourfee = p.ourfee || 0; + let credit = Math.round(total * config.fee) - ourfee; + warn("crediting balance", total + maxfee + ourfee); + await db.incrBy(`balance:${p.uid}`, total + maxfee + ourfee); warn("crediting credits", credit); await db.incrBy(`credit:${types.lightning}:${p.uid}`, credit); |
