aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/db.ts7
-rw-r--r--lib/payments.ts2
-rw-r--r--routes/payments.ts1
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/db.ts b/lib/db.ts
index 82fa2cec..50c78e85 100644
--- a/lib/db.ts
+++ b/lib/db.ts
@@ -32,6 +32,8 @@ local paymentKey = KEYS[1]
local balanceKey = KEYS[2]
local creditKey = KEYS[3]
local hashKey = KEYS[4]
+local paymentsKey = KEYS[5]
+local pid = KEYS[6]
local total = tonumber(ARGV[1])
local credit = tonumber(ARGV[2])
@@ -43,9 +45,10 @@ if payment ~= nil then
redis.call('incrby', creditKey, credit)
redis.call('del', paymentKey)
redis.call('del', hashKey)
+ redis.call('lrem', paymentsKey, 0, pid);
end
-return paymentKey
+return pid
`;
let debit = defineScript({
@@ -55,7 +58,7 @@ let debit = defineScript({
});
let reverse = defineScript({
- NUMBER_OF_KEYS: 4,
+ NUMBER_OF_KEYS: 6,
SCRIPT: REVERSE,
transformArguments: (...args) => args.map((a) => a.toString()),
});
diff --git a/lib/payments.ts b/lib/payments.ts
index 1f1497ec..cc55e5ce 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -818,6 +818,8 @@ let reverse = async (p) => {
`balance:${p.uid}`,
`credit:${types.lightning}:${p.uid}`,
`payment:${p.hash}`,
+ `${p.uid}:payments`,
+ p.id,
total,
credit,
);
diff --git a/routes/payments.ts b/routes/payments.ts
index 5eb802bc..33f66e8d 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -95,6 +95,7 @@ export default {
let p = await g(`payment:${pid}`);
if (!p) {
warn("user", id, "missing payment", pid);
+ await db.lRem(`${aid || id}:payments`, 0, pid);
return p;
}
if (p.created < start || p.created > end) return;