aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-12 23:29:09 -0700
committerAdam Soltys <[email protected]>2023-03-12 23:29:09 -0700
commit5d42bd231f4f42235bfc53d7561ba9dfb0dc6697 (patch)
treea7885b02422074aceb594783052b02b4d639450e /lib
parent5955ff6969a5301c4413631b76cf2300d193f8ed (diff)
downloadcoinos-server-5d42bd231f4f42235bfc53d7561ba9dfb0dc6697.tar.gz
coinos-server-5d42bd231f4f42235bfc53d7561ba9dfb0dc6697.zip
fix tip bug
Diffstat (limited to 'lib')
-rw-r--r--lib/payments.js10
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";