From 38ba24080dd50b1993772ba822c3db83876c4fd3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 10 May 2021 09:52:46 -0700 Subject: catch liquid send errors --- index.js | 1 - routes/liquid/send.js | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 1178c71b..7304862f 100644 --- a/index.js +++ b/index.js @@ -96,7 +96,6 @@ app.use((err, req, res, next) => { "Cache-Control": "no-cache" }); res.send(err.message); - return res.end(); }); server.listen(config.port, () => diff --git a/routes/liquid/send.js b/routes/liquid/send.js index a3bb7639..0729370c 100644 --- a/routes/liquid/send.js +++ b/routes/liquid/send.js @@ -67,7 +67,8 @@ sendLiquid = async ({ user, address, memo, tx, limit }) => { } } - if (limit && total > limit) throw new Error("Tx amount exceeds authorized amount"); + if (limit && total > limit) + throw new Error("Tx amount exceeds authorized amount"); if (asset !== btc || total) { l.info("creating liquid payment", user.username, asset, total, fee); @@ -147,13 +148,13 @@ sendLiquid = async ({ user, address, memo, tx, limit }) => { module.exports = ah(async (req, res) => { let { user } = req; - let { address, feeRate, memo, tx } = req.body; - - if (!tx) { - ({ tx } = await liquidTx({ ...req.body, user })); - } try { + let { address, feeRate, memo, tx } = req.body; + + if (!tx) { + ({ tx } = await liquidTx({ ...req.body, user })); + } res.send(await sendLiquid({ user, address, memo, tx })); } catch (e) { l.error("problem sending liquid", user.username, e.message); -- cgit v1.2.3