diff options
| author | Adam Soltys <[email protected]> | 2023-03-12 23:29:09 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-12 23:29:09 -0700 |
| commit | 5d42bd231f4f42235bfc53d7561ba9dfb0dc6697 (patch) | |
| tree | a7885b02422074aceb594783052b02b4d639450e | |
| parent | 5955ff6969a5301c4413631b76cf2300d193f8ed (diff) | |
| download | coinos-server-5d42bd231f4f42235bfc53d7561ba9dfb0dc6697.tar.gz coinos-server-5d42bd231f4f42235bfc53d7561ba9dfb0dc6697.zip | |
fix tip bug
| -rw-r--r-- | lib/payments.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/payments.js b/lib/payments.js index 0a59a868..8200cdb0 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -95,8 +95,11 @@ export let debit = async ( export let credit = async (hash, amount, memo, ref, type = types.internal) => { amount = parseInt(amount); + let invoice = await g(`invoice:${hash}`); if (!invoice) return warn("failed to credit", hash, ", invoice not found"); + + let { tip } = invoice; if (!memo) ({ memo } = invoice); let user = await g(`user:${invoice.uid}`); @@ -114,17 +117,12 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { currency, memo, ref, + tip, type, confirmed: true, created: Date.now(), }; - let { tip } = invoice; - if (tip) { - p.tip = tip; - p.amount -= tip; - } - invoice.received += amount; let balance = "balance"; |
