aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-08-13 09:21:18 -0400
committerAdam Soltys <[email protected]>2021-08-13 09:21:18 -0400
commit321ce8473ec1a9df367af057c6e35e228e926e65 (patch)
tree72fea8fce4a16ea50f242c96c8391d80d194bd74
parent30598010bf13159b62ef77fde9c3338bb405f270 (diff)
downloadcoinos-server-321ce8473ec1a9df367af057c6e35e228e926e65.tar.gz
coinos-server-321ce8473ec1a9df367af057c6e35e228e926e65.zip
lnurlp endpoint
-rw-r--r--routes/lnurl.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js
index 67f581d1..feceb913 100644
--- a/routes/lnurl.js
+++ b/routes/lnurl.js
@@ -115,6 +115,41 @@ app.post(
);
app.get(
+ "/lnurlp/:username",
+ ah(async (req, res, next) => {
+ const { username } = req.params;
+ let user = await db.User.findOne({
+ where: {
+ username
+ }
+ });
+
+ let { amount, minSendable, maxSendable } = req.query;
+ minSendable = minSendable || 1000;
+ maxSendable = maxSendable || 1000000000;
+ if (parseInt(amount)) minSendable = maxSendable = amount * 1000;
+
+ try {
+ let result = await lnurlServer.generateNewUrl("payRequest", {
+ minSendable,
+ maxSendable,
+ metadata: JSON.stringify([["text/plain", `paying ${user.username}`]])
+ });
+
+ recipients[result.secret] = user;
+ l.info("recipient", user.username, result.secret);
+
+ result = await axios.get(result.url);
+
+ res.send(result.data);
+ } catch (e) {
+ l.error("problem generating payment url", e.message);
+ res.status(500).send(e.message);
+ }
+ })
+);
+
+app.get(
"/pay/:username",
ah(async (req, res, next) => {
const { username } = req.params;