Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lnbits broken after lnurl-pay support #310

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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