aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/db.js2
-rw-r--r--lib/payments.js7
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/db.js b/lib/db.js
index 61859dcb..6a84a7a2 100644
--- a/lib/db.js
+++ b/lib/db.js
@@ -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);