aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/send.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-04-27 21:42:10 -0700
committerAdam Soltys <[email protected]>2020-04-28 22:33:02 -0700
commit994dd93f6c45c590ae59a699cbf425d96518da1e (patch)
tree89b2a980fbad1e964e91ca3750b89051ddfb32f0 /routes/lightning/send.js
parente166ab2c743e4c66eacb51c6484711c5965dd090 (diff)
downloadcoinos-server-994dd93f6c45c590ae59a699cbf425d96518da1e.tar.gz
coinos-server-994dd93f6c45c590ae59a699cbf425d96518da1e.zip
fix lightning payments
Diffstat (limited to 'routes/lightning/send.js')
-rw-r--r--routes/lightning/send.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/routes/lightning/send.js b/routes/lightning/send.js
index 0d2025ad..02149aa8 100644
--- a/routes/lightning/send.js
+++ b/routes/lightning/send.js
@@ -57,10 +57,6 @@ module.exports = async (req, res) => {
let total = parseInt(m.payment_route.total_amt);
let fee = m.payment_route.total_fees;
- user.balance -= total - payreq.satoshis;
-
- await user.save();
-
const account = await db.Account.findOne({
where: {
user_id: user.id,
@@ -68,6 +64,9 @@ module.exports = async (req, res) => {
}
});
+ account.balance -= total - payreq.satoshis;
+ await account.save()
+
const payment = await db.Payment.create({
amount: -total,
account_id: account.id,
@@ -79,14 +78,11 @@ module.exports = async (req, res) => {
network: "LNBTC"
});
- user = await getUser(user.username);
-
seen.push(m.payment_preimage);
+ l.info("sent lightning", user.username, -payment.amount, m);
- l.info("sent lightning", user.username, -payment.amount);
+ user = await getUser(user.username);
emit(user.username, "payment", payment);
-
- l.info("user payments", user.payments);
emit(user.username, "user", user);
if (payreq.payeeNodeKey === config.lnb.id) {