Skip to content

Commit 018f9a1

Browse files
authored
fix: lnbits broken after lnurl-pay support (#310)
1 parent fdf49ff commit 018f9a1

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/@types/invoice.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export interface Invoice {
2828
verifyURL?: string
2929
}
3030

31+
export interface LnurlInvoice extends Invoice {
32+
verifyURL: string
33+
}
34+
3135
export interface DBInvoice {
3236
id: string
3337
pubkey: Buffer

src/payments-processors/lnurl-payments-processor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AxiosInstance } from 'axios'
22
import { Factory } from '../@types/base'
33

44
import { CreateInvoiceRequest, GetInvoiceResponse, IPaymentsProcessor } from '../@types/clients'
5-
import { Invoice, InvoiceStatus, InvoiceUnit } from '../@types/invoice'
5+
import { InvoiceStatus, InvoiceUnit, LnurlInvoice } from '../@types/invoice'
66
import { createLogger } from '../factories/logger-factory'
77
import { randomUUID } from 'crypto'
88
import { Settings } from '../@types/settings'
@@ -15,7 +15,7 @@ export class LnurlPaymentsProcesor implements IPaymentsProcessor {
1515
private settings: Factory<Settings>
1616
) {}
1717

18-
public async getInvoice(invoice: Invoice): Promise<GetInvoiceResponse> {
18+
public async getInvoice(invoice: LnurlInvoice): Promise<GetInvoiceResponse> {
1919
debug('get invoice: %s', invoice.id)
2020

2121
try {

src/services/payments-service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ export class PaymentsService implements IPaymentsService {
3535
}
3636
}
3737

38-
public async getInvoiceFromPaymentsProcessor(invoice: Invoice): Promise<Partial<Invoice>> {
39-
debug('get invoice %s from payment processor', invoice.id)
38+
public async getInvoiceFromPaymentsProcessor(invoice: Invoice | string): Promise<Partial<Invoice>> {
4039
try {
4140
return await this.paymentsProcessor.getInvoice(
42-
this.settings().payments?.processor === 'lnurl' ? invoice : invoice.id
41+
typeof invoice === 'string' ? invoice : invoice.id
4342
)
4443
} catch (error) {
4544
console.log('Unable to get invoice from payments processor. Reason:', error)

0 commit comments

Comments
 (0)