Support LNURL-verify (#1103)

This commit is contained in:
ekzyis 2024-04-24 03:28:25 +02:00 committed by GitHub
parent 255f97a2b3
commit cc7d9d734c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -90,7 +90,8 @@ export default async ({ query: { username, amount, nostr, comment, payerdata: pa
return res.status(200).json({
pr: invoice.request,
routes: []
routes: [],
verify: `${process.env.NEXT_PUBLIC_URL}/api/lnurlp/${username}/verify/${invoice.id}`
})
} catch (error) {
console.log(error)

View File

@ -0,0 +1,15 @@
import lnd from '@/api/lnd'
import { getInvoice } from 'ln-service'
export default async ({ query: { hash } }, res) => {
try {
const inv = await getInvoice({ id: hash, lnd })
const settled = inv.is_confirmed
return res.status(200).json({ status: 'OK', settled, preimage: settled ? inv.secret : null, pr: inv.request })
} catch (err) {
if (err[1] === 'UnexpectedLookupInvoiceErr') {
return res.status(404).json({ status: 'ERROR', reason: 'not found' })
}
return res.status(500).json({ status: 'ERROR', reason: 'internal server error' })
}
}