diff options
| author | Adam Soltys <[email protected]> | 2024-01-23 15:22:05 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-01-23 15:22:08 -0800 |
| commit | 9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99 (patch) | |
| tree | 7637d90396c0006527c44a0e69cf6f2f2a7aa0b3 /lib/payments.js | |
| parent | 05967b7d4b004860113ea44cf1b01b9135437f1e (diff) | |
| download | coinos-server-9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99.tar.gz coinos-server-9c7d46dbd78e4ba217adbc9d48fbd6e91f5fad99.zip | |
format
Diffstat (limited to 'lib/payments.js')
| -rw-r--r-- | lib/payments.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/payments.js b/lib/payments.js index 8da04b38..550e3791 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, @@ -89,7 +89,7 @@ export let debit = async ({ amount: -amount, fee, hash, - ourfee: r.ourfee, + ourfee: r.ourfee, memo, iid, uid, @@ -188,9 +188,6 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { .incrBy(`${balance}:${uid}`, amount) .exec(); - if (!username.startsWith("lightning")) - l(username, "received", type, amount, tip); - emit(uid, "payment", p); notify(user, `Received ${amount} sats`); callWebhook(invoice, p); @@ -383,7 +380,10 @@ export let build = async ({ amount, address, feeRate }, user) => { let balance = await g(`balance:${user.id}`); if (amount + fee + ourfee > balance) { - if (amount <= fee + ourfee + dust) fail(`insufficient funds ⚡️${balance} of ⚡️${amount + fee + ourfee + dust}`); + if (amount <= fee + ourfee + dust) + fail( + `insufficient funds ⚡️${balance} of ⚡️${amount + fee + ourfee + dust}`, + ); outs = [{ [address]: btc(amount - ourfee) }]; raw = await node.createRawTransaction([], outs, 0, replaceable); @@ -403,7 +403,7 @@ export let build = async ({ amount, address, feeRate }, user) => { let seen; export let catchUp = async () => { try { - if (!seen) seen = await db.sMembers("missing"); + if (!seen) seen = await db.sMembers("missing"); let txns = []; for (let [type, n] of Object.entries({ bitcoin: bc, liquid: lq })) { txns.push( @@ -432,4 +432,3 @@ export let catchUp = async () => { setTimeout(catchUp, 2000); }; - |
