diff options
| author | Adam Soltys <[email protected]> | 2025-05-11 16:31:42 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-05-11 16:31:42 -0700 |
| commit | bed887ae567acd4f8480bd3e2726474f79021714 (patch) | |
| tree | 72545f4a532792cc0ced2370a1f7512886bfcf10 /lib/db.ts | |
| parent | c7b93725a08333516c89bdb64f4b4149f6b0da2b (diff) | |
| download | coinos-server-bed887ae567acd4f8480bd3e2726474f79021714.tar.gz coinos-server-bed887ae567acd4f8480bd3e2726474f79021714.zip | |
check frozen balance
Diffstat (limited to 'lib/db.ts')
| -rw-r--r-- | lib/db.ts | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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))) |
