correct lnurlp nostr pubkey stuff

This commit is contained in:
keyan 2023-02-24 10:41:47 -06:00
parent 9afbe0abd8
commit a3e928dc42
1 changed files with 3 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import { getPublicKey } from 'nostr'
import models from '../../../../api/models'
import { lnurlPayMetadataString } from '../../../../lib/lnurl'
@ -7,20 +8,13 @@ export default async ({ query: { username } }, res) => {
return res.status(400).json({ status: 'ERROR', reason: `user @${username} does not exist` })
}
let nostr = {}
if (user.nostrPubkey) {
nostr = {
nostrPubkey: user.nostrPubkey,
allowsNostr: true
}
}
return res.status(200).json({
callback: `${process.env.PUBLIC_URL}/api/lnurlp/${username}/pay`, // The URL from LN SERVICE which will accept the pay request parameters
minSendable: 1000, // Min amount LN SERVICE is willing to receive, can not be less than 1 or more than `maxSendable`
maxSendable: 1000000000,
metadata: lnurlPayMetadataString(username), // Metadata json which must be presented as raw string here, this is required to pass signature verification at a later step
tag: 'payRequest', // Type of LNURL
...nostr
nostrPubkey: getPublicKey(process.env.NOSTR_PRIVATE_KEY),
allowsNostr: true
})
}