diff options
| author | Adam Soltys <[email protected]> | 2023-05-03 17:26:45 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-05-03 17:26:50 +0000 |
| commit | f695cbd6d1ed9d8560363693c0f3bdcb7c78c7d8 (patch) | |
| tree | 096915c34f6157ef9763c0fe91145ba52dc1fc24 /routes/lnurl.js | |
| parent | 1b8f6a552f10a02f1b752ae7ed9920ff40de9edd (diff) | |
| download | coinos-server-f695cbd6d1ed9d8560363693c0f3bdcb7c78c7d8.tar.gz coinos-server-f695cbd6d1ed9d8560363693c0f3bdcb7c78c7d8.zip | |
error handling
Diffstat (limited to 'routes/lnurl.js')
| -rw-r--r-- | routes/lnurl.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js index 5cfb26bb..14f848a4 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -34,11 +34,15 @@ export default { }, async decode({ query: { text } }, res) { - let url = Buffer.from( - bech32.fromWords(bech32.decode(text, 20000).words) - ).toString(); + try { + let url = Buffer.from( + bech32.fromWords(bech32.decode(text, 20000).words) + ).toString(); - res.send(await got(url).json()); + res.send(await got(url).json()); + } catch (e) { + bail(res, e.message); + } }, async lnurlp({ params: { username } }, res) { @@ -92,7 +96,7 @@ export default { let uid = await g(`lnurl:${id}`); let user = await g(`user:${uid}`); let { username } = user; - username = username.replace(/\s/g, '').toLowerCase(); + username = username.replace(/\s/g, "").toLowerCase(); let metadata = JSON.stringify([ ["text/plain", `Paying ${username}@${host}`], |
