Support LNURL-verify (#1103)
This commit is contained in:
		
							parent
							
								
									255f97a2b3
								
							
						
					
					
						commit
						cc7d9d734c
					
				@ -90,7 +90,8 @@ export default async ({ query: { username, amount, nostr, comment, payerdata: pa
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return res.status(200).json({
 | 
					    return res.status(200).json({
 | 
				
			||||||
      pr: invoice.request,
 | 
					      pr: invoice.request,
 | 
				
			||||||
      routes: []
 | 
					      routes: [],
 | 
				
			||||||
 | 
					      verify: `${process.env.NEXT_PUBLIC_URL}/api/lnurlp/${username}/verify/${invoice.id}`
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    console.log(error)
 | 
					    console.log(error)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								pages/api/lnurlp/[username]/verify/[hash].js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								pages/api/lnurlp/[username]/verify/[hash].js
									
									
									
									
									
										Normal 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' })
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user