aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routes/payments.js46
1 files changed, 24 insertions, 22 deletions
diff --git a/routes/payments.js b/routes/payments.js
index 307e8ef6..784bf2f3 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -31,7 +31,7 @@ export default {
await got
.post(`${config.classic}/admin/credit`, {
json: { username, amount, source },
- headers: { authorization: `Bearer ${config.admin}` }
+ headers: { authorization: `Bearer ${config.admin}` },
})
.json();
} else if (payreq) {
@@ -99,7 +99,7 @@ export default {
let payments = (await db.lRange(`${id}:payments`, 0, -1)) || [];
payments = (
await Promise.all(
- payments.map(async id => {
+ payments.map(async (id) => {
let p = await g(`payment:${id}`);
if (p.created < start || p.created > end) return;
if (p.type === types.internal) p.with = await g(`user:${p.ref}`);
@@ -107,7 +107,7 @@ export default {
})
)
)
- .filter(p => p)
+ .filter((p) => p)
.sort((a, b) => b.created - a.created);
let total = payments.length;
@@ -134,7 +134,7 @@ export default {
let twoWeeksAgo = new Date(new Date().setDate(new Date().getDate() - 14));
let decoded = await ln.decodepay(payreq);
let { msatoshi, payee } = decoded;
- let node = nodes.find(n => n.nodeid === payee);
+ let node = nodes.find((n) => n.nodeid === payee);
let alias = node ? node.alias : payee.substr(0, 12);
res.send({ alias, amount: Math.round(msatoshi / 1000) });
@@ -144,13 +144,13 @@ export default {
let amount = await g(`pot:${name}`);
if (!amount) return bail(res, "pot not found");
let payments = (await db.lRange(`pot:${name}:payments`, 0, -1)) || [];
- payments = await Promise.all(payments.map(hash => g(`payment:${hash}`)));
+ payments = await Promise.all(payments.map((hash) => g(`payment:${hash}`)));
await Promise.all(
- payments.map(async p => (p.user = await g(`user:${p.uid}`)))
+ payments.map(async (p) => (p.user = await g(`user:${p.uid}`)))
);
- payments = payments.filter(p => p);
+ payments = payments.filter((p) => p);
res.send({ amount, payments });
},
@@ -158,16 +158,13 @@ export default {
amount = parseInt(amount);
await t(`pot:${name}`, async (balance, db) => {
if (balance < amount) fail("Insufficient funds");
- await db
- .multi()
- .decrBy(`pot:${name}`, amount)
- .exec();
+ await db.multi().decrBy(`pot:${name}`, amount).exec();
});
let hash = v4();
await s(`invoice:${hash}`, {
uid: user.id,
- received: 0
+ received: 0,
});
let payment = await credit(hash, amount, "", name, types.pot);
@@ -227,7 +224,7 @@ export default {
let tx = await bc.fundRawTransaction(raw, {
feeRate,
subtractFeeFromOutputs,
- replaceable
+ replaceable,
});
let fee = sats(tx.fee);
@@ -270,7 +267,7 @@ export default {
for (let {
scriptPubKey: { address },
- value
+ value,
} of tx.vout) {
total += sats(value);
if (
@@ -307,13 +304,13 @@ export default {
"card[number]": number,
"card[exp_month]": month,
"card[exp_year]": year,
- "card[cvc]": cvc
+ "card[cvc]": cvc,
};
let { id: source } = await got
.post(`${stripe}/tokens`, {
form,
- username
+ username,
})
.json();
@@ -322,13 +319,13 @@ export default {
amount,
currency,
source,
- description: "starter coupon"
+ description: "starter coupon",
};
let r = await got
.post(`${stripe}/charges`, {
form,
- username
+ username,
})
.json();
@@ -338,7 +335,7 @@ export default {
let memo = "stripe";
await s(`invoice:${hash}`, {
uid: user.id,
- received: 0
+ received: 0,
});
amount = sats(amount / store.rates[currency]);
let uid = await g("user:coinos");
@@ -358,7 +355,7 @@ export default {
"estimatesmartfee",
"echo",
"getblockchaininfo",
- "getnetworkinfo"
+ "getnetworkinfo",
];
if (!whitelist.includes(method)) fail("unsupported method");
@@ -368,9 +365,14 @@ export default {
if (method === "getblock") params[1] = parseInt(params[1]);
- res.send(await bc[method](...params));
+ let result = await bc[method](...params);
+
+ if (result.feerate)
+ result.feerate = result.feerate.toFixed(8);
+
+ res.send(result);
} catch (e) {
bail(res, e.message);
}
- }
+ },
};