aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/payments.js9
-rw-r--r--lib/utils.js1
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/payments.js b/lib/payments.js
index af08cb84..d25df227 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -18,16 +18,15 @@ export const types = {
export let debit = async (
hash,
amount,
+ fee = 0,
memo,
user,
type = types.internal,
id = v4()
) => {
- console.log("HASH", hash)
let ref;
let invoice = await g(`invoice:${hash}`);
if (invoice) ref = invoice.uid;
- console.log("REF", ref)
let { id: uid, currency, username } = user;
@@ -41,13 +40,13 @@ export let debit = async (
return balance - amount;
});
- let fee = 0;
-
let p = {
id,
amount: -amount,
+ fee,
memo,
uid,
+ confirmed: true,
rate: store.rates[currency],
currency,
type,
@@ -102,7 +101,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
balance = "pending";
} else {
p.id = hash;
- }
+ }
await db
.multi()
diff --git a/lib/utils.js b/lib/utils.js
index b65f179a..e58f7d1f 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -24,6 +24,7 @@ export const fail = msg => {
export const SATS = 100000000;
export const sats = n => Math.round(n * SATS);
+export const btc = n => parseFloat((n / SATS).toFixed(8));
export const uniq = (a, k) => [...new Map(a.map(x => [k(x), x])).values()];
export const pick = (O, K) =>