diff --git a/src/services/lnd/liquidityProvider.ts b/src/services/lnd/liquidityProvider.ts index ef5c4c10..cb703f33 100644 --- a/src/services/lnd/liquidityProvider.ts +++ b/src/services/lnd/liquidityProvider.ts @@ -47,16 +47,16 @@ export class LiquidityProvider { }, 1000) } - AwaitProviderReady = async (res: (usable: boolean) => void) => { + AwaitProviderReady = async (): Promise => { if (!this.pubDestination) { - res(false) - return + return false } if (this.latestMaxWithdrawable !== null) { - res(true) - return + return true } - this.queue.push({ res }) + return new Promise(res => { + this.queue.push({ res }) + }) } Stop = () => { diff --git a/src/services/main/sanityChecker.ts b/src/services/main/sanityChecker.ts index 372dd96c..e4079e60 100644 --- a/src/services/main/sanityChecker.ts +++ b/src/services/main/sanityChecker.ts @@ -236,9 +236,15 @@ export default class SanityChecker { this.events = await this.storage.eventsLog.GetAllLogs() this.invoices = (await this.lnd.GetAllPaidInvoices(1000)).invoices this.payments = (await this.lnd.GetAllPayments(1000)).payments - const ops = await this.lnd.liquidProvider.GetOperations() - this.providerInvoices = ops.latestIncomingInvoiceOperations.operations - this.providerPayments = ops.latestOutgoingInvoiceOperations.operations + const providerUsable = await this.lnd.liquidProvider.AwaitProviderReady() + if (providerUsable) { + const ops = await this.lnd.liquidProvider.GetOperations() + this.providerInvoices = ops.latestIncomingInvoiceOperations.operations + this.providerPayments = ops.latestOutgoingInvoiceOperations.operations + } else { + this.log("provider not usable, skipping provider checks") + } + this.incrementSources = {} this.decrementSources = {} this.users = {}