diff options
| author | Adam Soltys <[email protected]> | 2020-07-16 12:06:25 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-07-16 12:06:25 -0700 |
| commit | 79c9febb88035422e950349b214cc1fc1a4ab615 (patch) | |
| tree | c2e2b82dda2185508ec26932780bf2bbfef906e7 /routes | |
| parent | dabde17d34eda659292382343026382907b76fe4 (diff) | |
| download | coinos-server-79c9febb88035422e950349b214cc1fc1a4ab615.tar.gz coinos-server-79c9febb88035422e950349b214cc1fc1a4ab615.zip | |
url codes
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/lnurl.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js index 709e1fc5..82f0f575 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -17,17 +17,40 @@ var optionalAuth = function (req, res, next) { })(req, res, next); }; +app.get("/url", async (req, res) => { + try { + const { text } = await db.Code.findOne({ + where: { + code: req.query.code, + }, + }); + + if (text) { + res.send(text); + } else { + throw new Error('code not found'); + } + } catch (e) { + l.error("couldn't find url", e.message); + } +}); + app.get("/withdraw", auth, async (req, res) => { const { min, max } = req.query; try { const result = await lnurlServer.generateNewUrl("withdrawRequest", { minWithdrawable: min * 1000, maxWithdrawable: max * 1000, - defaultDescription: "coinos withdrawal", + defaultDescription: "coinos voucher", }); withdrawals[result.secret] = req.user; + await db.Code.create({ + code: result.encoded.substr(64), + text: result.encoded, + }); + res.send(result); } catch (e) { l.error("problem generating withdrawl url", e.message); |
