From 5d42bd231f4f42235bfc53d7561ba9dfb0dc6697 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 12 Mar 2023 23:29:09 -0700 Subject: fix tip bug --- lib/payments.js | 10 ++++------ 1 file 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"; -- cgit v1.2.3