aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;