aboutsummaryrefslogtreecommitdiffstats
path: root/lib/db.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-05-11 16:31:42 -0700
committerAdam Soltys <[email protected]>2025-05-11 16:31:42 -0700
commitbed887ae567acd4f8480bd3e2726474f79021714 (patch)
tree72545f4a532792cc0ced2370a1f7512886bfcf10 /lib/db.ts
parentc7b93725a08333516c89bdb64f4b4149f6b0da2b (diff)
downloadcoinos-server-bed887ae567acd4f8480bd3e2726474f79021714.tar.gz
coinos-server-bed887ae567acd4f8480bd3e2726474f79021714.zip
check frozen balance
Diffstat (limited to 'lib/db.ts')
-rw-r--r--lib/db.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/db.ts b/lib/db.ts
index 57b53037..7a779485 100644
--- a/lib/db.ts
+++ b/lib/db.ts
@@ -10,6 +10,8 @@ local amount = tonumber(ARGV[1])
local tip = tonumber(ARGV[2])
local fee = tonumber(ARGV[3])
local ourfee = tonumber(ARGV[4])
+local frozen = tonumber(ARGV[5])
+local insufficientString = ARGV[6];
local balance = tonumber(redis.call('get', balanceKey) or '0')
local credit = tonumber(redis.call('get', creditKey) or '0')
@@ -17,8 +19,8 @@ local credit = tonumber(redis.call('get', creditKey) or '0')
local covered = math.min(credit, ourfee)
ourfee = ourfee - covered
-if balance < amount + tip + fee + ourfee then
- return {err = 'Insufficient funds ⚡️' .. balance .. ' of ⚡️' .. amount + tip + fee + ourfee}
+if balance - frozen < amount + tip + fee + ourfee then
+ return {err = insufficientString .. '⚡️' .. balance - frozen .. ' / ' .. amount + tip + fee + ourfee}
end
redis.call('decrby', creditKey, tostring(math.floor(covered)))