4ce395889d
* cache or remove unecessary calls to lnd * avoid redundant grpc calls in state machine * store preimage whenever available * enhancements post self-code review * small refinements * fixes * fix lnurl-verify * prevent wallet logger throwing on idb close * fix promise in race while waiting for payment
16 lines
566 B
JavaScript
16 lines
566 B
JavaScript
import models from '@/api/models'
|
|
|
|
export default async ({ query: { hash } }, res) => {
|
|
try {
|
|
const inv = await models.invoice.findUnique({ where: { hash } })
|
|
if (!inv) {
|
|
return res.status(404).json({ status: 'ERROR', reason: 'not found' })
|
|
}
|
|
const settled = inv.confirmedAt
|
|
return res.status(200).json({ status: 'OK', settled: !!settled, preimage: settled ? inv.preimage : null, pr: inv.bolt11 })
|
|
} catch (err) {
|
|
console.log('error', err)
|
|
return res.status(500).json({ status: 'ERROR', reason: 'internal server error' })
|
|
}
|
|
}
|