aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/payments.js')
-rw-r--r--lib/payments.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/payments.js b/lib/payments.js
index 19d044e2..733e04ce 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -38,7 +38,8 @@ export let debit = async (
let rate = store.rates[currency];
- let invoice = await g(`invoice:${hash}`);
+ let iid = await g(`invoice:${hash}`);
+ let invoice = await g(`invoice:${iid}`);
if (invoice) {
ref = invoice.uid;
@@ -91,6 +92,7 @@ export let debit = async (
hash,
ourfee,
memo,
+ iid,
uid,
confirmed: true,
rate,
@@ -113,7 +115,8 @@ export let debit = async (
export let credit = async (hash, amount, memo, ref, type = types.internal) => {
amount = parseInt(amount) || 0;
- let invoice = await g(`invoice:${hash}`);
+ let iid = await g(`invoice:${hash}`);
+ let invoice = await g(`invoice:${iid}`);
if (!invoice) return warn("failed to credit", hash, ", invoice not found");
let { tip } = invoice;
@@ -170,7 +173,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
if ([types.bitcoin, types.lightning].includes(type))
m.incrBy(`credit:${type}:${uid}`, Math.round(amount * config.fee));
- m.set(`invoice:${hash}`, JSON.stringify(invoice))
+ m.set(`invoice:${iid}`, JSON.stringify(invoice))
.set(`payment:${p.id}`, JSON.stringify(p))
.lPush(`${uid}:payments`, p.id)
.incrBy(`${balance}:${uid}`, amount)