From 5c08be8c0ebf10e0d0fab8021f35dc2f0e623ddb Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 29 Dec 2018 14:59:00 -0800 Subject: save fb token and check user balance --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 05411d35..e47cebb9 100644 --- a/index.js +++ b/index.js @@ -365,6 +365,9 @@ const l = console.log amount = req.user.balance - MINFEE } + if (amount > req.user.balance) + return res.status(401).send('Insufficient funds') + try { await bc.walletPassphrase(config.bitcoin.walletpass, 300) let txid = await bc.sendToAddress(address, (amount / 100000000).toFixed(8)) @@ -395,10 +398,6 @@ const l = console.log l(e) let msg = e.message - if (msg.startsWith('insufficient')) { - msg = 'Server wallet is busy. Wait a block and try again' - } - res.status(500).send(msg) } }) @@ -493,7 +492,8 @@ const l = console.log if (!user) { user = await db.User.create(user) - user.username = req.body.userID + user.username = userID + user.fbtoken = accessToken user.address = (await lna.newAddress({ type: 1 }, lna.meta)).address user.password = await bcrypt.hash(accessToken, 1) let friends = (await fb.api(`/${userID}/friends?access_token=${accessToken}`)).data -- cgit v1.2.3