2024-10-02 20:03:30 +00:00
|
|
|
import models from '@/api/models'
|
2024-04-24 01:28:25 +00:00
|
|
|
|
|
|
|
export default async ({ query: { hash } }, res) => {
|
|
|
|
try {
|
2024-10-02 20:03:30 +00:00
|
|
|
const inv = await models.invoice.findUnique({ where: { hash } })
|
|
|
|
if (!inv) {
|
2024-04-24 01:28:25 +00:00
|
|
|
return res.status(404).json({ status: 'ERROR', reason: 'not found' })
|
|
|
|
}
|
2024-11-16 00:38:14 +00:00
|
|
|
const settled = !!inv.confirmedAt
|
|
|
|
return res.status(200).json({
|
|
|
|
status: 'OK',
|
|
|
|
settled,
|
|
|
|
preimage: settled ? inv.preimage : null,
|
|
|
|
pr: inv.bolt11
|
|
|
|
})
|
2024-10-02 20:03:30 +00:00
|
|
|
} catch (err) {
|
|
|
|
console.log('error', err)
|
2024-04-24 01:28:25 +00:00
|
|
|
return res.status(500).json({ status: 'ERROR', reason: 'internal server error' })
|
|
|
|
}
|
|
|
|
}
|