diff options
| author | Adam Soltys <[email protected]> | 2024-01-23 12:51:20 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-01-23 12:51:26 -0800 |
| commit | 517065e5bd34f7e1d5c27ce8c86476cd0810636a (patch) | |
| tree | 3787d520e70b34c9859088a8c4c406c78f032268 /lib | |
| parent | 5b77684192f08cb29a3bbaf2a87413d4c4e8cc1b (diff) | |
| download | coinos-server-517065e5bd34f7e1d5c27ce8c86476cd0810636a.tar.gz coinos-server-517065e5bd34f7e1d5c27ce8c86476cd0810636a.zip | |
return ourfee minus covered credits
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/db.js | 2 | ||||
| -rw-r--r-- | lib/payments.js | 6 |
2 files changed, 4 insertions, 4 deletions
@@ -24,7 +24,7 @@ end redis.call('decrby', creditKey, tostring(math.floor(covered))) redis.call('decrby', balanceKey, tostring(math.floor(amount + tip + fee + ourfee))) -return {ok = 'ok'} +return {ok = ourfee} `; let debit = defineScript({ diff --git a/lib/payments.js b/lib/payments.js index 796ad18b..8da04b38 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -72,7 +72,7 @@ export let debit = async ({ ? Math.round(amount * config.fee) : 0; - let r = await db.debit( + let r = await db.debit( `balance:${uid}`, `credit:${type}:${uid}`, amount || 0, @@ -81,7 +81,7 @@ export let debit = async ({ ourfee || 0, ); - if (r !== "ok") fail("Problem debiting account"); + if (!r || r.err) fail("Problem debiting account"); let id = v4(); let p = { @@ -89,7 +89,7 @@ export let debit = async ({ amount: -amount, fee, hash, - ourfee, + ourfee: r.ourfee, memo, iid, uid, |
