fix: lnbits broken after lnurl-pay support (#310)

This commit is contained in:
Ricardo Arturo Cabral Mejía 2023-05-19 10:10:30 -04:00 committed by GitHub
parent fdf49ff59f
commit 018f9a14fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -28,6 +28,10 @@ export interface Invoice {
verifyURL?: string
}
export interface LnurlInvoice extends Invoice {
verifyURL: string
}
export interface DBInvoice {
id: string
pubkey: Buffer

View File

@ -2,7 +2,7 @@ import { AxiosInstance } from 'axios'
import { Factory } from '../@types/base'
import { CreateInvoiceRequest, GetInvoiceResponse, IPaymentsProcessor } from '../@types/clients'
import { Invoice, InvoiceStatus, InvoiceUnit } from '../@types/invoice'
import { InvoiceStatus, InvoiceUnit, LnurlInvoice } from '../@types/invoice'
import { createLogger } from '../factories/logger-factory'
import { randomUUID } from 'crypto'
import { Settings } from '../@types/settings'
@ -15,7 +15,7 @@ export class LnurlPaymentsProcesor implements IPaymentsProcessor {
private settings: Factory<Settings>
) {}
public async getInvoice(invoice: Invoice): Promise<GetInvoiceResponse> {
public async getInvoice(invoice: LnurlInvoice): Promise<GetInvoiceResponse> {
debug('get invoice: %s', invoice.id)
try {

View File

@ -35,11 +35,10 @@ export class PaymentsService implements IPaymentsService {
}
}
public async getInvoiceFromPaymentsProcessor(invoice: Invoice): Promise<Partial<Invoice>> {
debug('get invoice %s from payment processor', invoice.id)
public async getInvoiceFromPaymentsProcessor(invoice: Invoice | string): Promise<Partial<Invoice>> {
try {
return await this.paymentsProcessor.getInvoice(
this.settings().payments?.processor === 'lnurl' ? invoice : invoice.id
typeof invoice === 'string' ? invoice : invoice.id
)
} catch (error) {
console.log('Unable to get invoice from payments processor. Reason:', error)