diff options
| author | Gyulai Zoltan <[email protected]> | 2021-10-12 13:53:33 +0300 |
|---|---|---|
| committer | Gyulai Zoltan <[email protected]> | 2021-10-12 13:53:33 +0300 |
| commit | 92ffc6e2e597867a55b592a20b16c233efad9cef (patch) | |
| tree | 9bfad78872592637a241624de9edde36986b4b07 /routes | |
| parent | 5f949a00ab98792db22bb5ab0104a06c714932f2 (diff) | |
| download | coinos-server-withdraw.tar.gz coinos-server-withdraw.zip | |
feat: added lightning withdrawal with hardcoded fee estimationwithdraw
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/lightning/withdraw.js | 11 | ||||
| -rw-r--r-- | routes/liquid/util/decrementacc.js | 3 | ||||
| -rw-r--r-- | routes/payments.js | 1 |
3 files changed, 12 insertions, 3 deletions
diff --git a/routes/lightning/withdraw.js b/routes/lightning/withdraw.js new file mode 100644 index 00000000..d1712d39 --- /dev/null +++ b/routes/lightning/withdraw.js @@ -0,0 +1,11 @@ +module.exports = ah(async (req, res) => { + let { amount, memo, payreq } = req.body; + let { user } = req; + + try { + res.send(await send(amount, memo, payreq, user, true)); + } catch (e) { + l.error("problem sending lightning withdrawal", user.username, e.message, e.stack); + res.status(500).send(e.message); + } +}); diff --git a/routes/liquid/util/decrementacc.js b/routes/liquid/util/decrementacc.js index 5be30e13..eca785e0 100644 --- a/routes/liquid/util/decrementacc.js +++ b/routes/liquid/util/decrementacc.js @@ -17,11 +17,8 @@ module.exports = async (user, transaction, limit, fee, assets, amount, address, }); if (faucet) { - // TODO: is faucet ok with 0 fee in withdraw? covered = faucet.balance; if (covered > fee) covered = fee; - // covered = fee; - // if (covered > faucet.balance) covered = faucet.balance; await faucet.decrement({balance: covered}, {transaction}); await faucet.reload({transaction}); await faucet.save({transaction}); diff --git a/routes/payments.js b/routes/payments.js index cb09de63..6f4601db 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -128,6 +128,7 @@ ah(async () => { app.post("/lightning/invoice", require("./lightning/invoice")); app.post("/lightning/query", auth, require("./lightning/query")); app.post("/lightning/send", auth, require("./lightning/send")); + app.post("/lightning/withdraw", auth, require("./lightning/withdraw")); require("./lightning/receive"); } |
