Skip to content

Commit

Permalink
fix: lnbits broken after lnurl-pay support (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameri authored May 19, 2023
1 parent fdf49ff commit 018f9a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/@types/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface Invoice {
verifyURL?: string
}

export interface LnurlInvoice extends Invoice {
verifyURL: string
}

export interface DBInvoice {
id: string
pubkey: Buffer
Expand Down
4 changes: 2 additions & 2 deletions src/payments-processors/lnurl-payments-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions src/services/payments-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 018f9a1

Please sign in to comment.