stacker.news/pages/api/lnurlp/[username]/index.js

18 lines
908 B
JavaScript
Raw Normal View History

2021-10-07 18:37:59 +00:00
import models from '../../../../api/models'
2021-10-07 21:03:54 +00:00
import { lnurlPayMetadataString } from '../../../../lib/lnurl'
2021-10-07 18:37:59 +00:00
export default async ({ query: { username } }, res) => {
const user = await models.user.findUnique({ where: { name: username } })
if (!user) {
return res.status(400).json({ status: 'ERROR', reason: `user @${username} does not exist` })
}
return res.status(200).json({
2022-01-25 20:28:50 +00:00
callback: `https://stacker.news/api/lnurlp/${username}/pay`, // The URL from LN SERVICE which will accept the pay request parameters
2021-10-07 18:37:59 +00:00
minSendable: 1000, // Min amount LN SERVICE is willing to receive, can not be less than 1 or more than `maxSendable`
2021-10-07 19:12:49 +00:00
maxSendable: Number.MAX_SAFE_INTEGER,
2021-10-07 21:03:54 +00:00
metadata: lnurlPayMetadataString(username), // Metadata json which must be presented as raw string here, this is required to pass signature verification at a later step
2021-10-07 18:37:59 +00:00
tag: 'payRequest' // Type of LNURL
})
}