diff --git a/src/services/main/index.ts b/src/services/main/index.ts index 3a82ad93..a1b96a82 100644 --- a/src/services/main/index.ts +++ b/src/services/main/index.ts @@ -5,7 +5,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js' import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js' import ProductManager from './productManager.js' import ApplicationManager from './applicationManager.js' -import PaymentManager from './paymentManager.js' +import PaymentManager, { PendingTx } from './paymentManager.js' import { MainSettings } from './settings.js' import NewLightningHandler, { LoadLndSettingsFromEnv, LightningHandler } from "../lnd/index.js" import { AddressPaidCb, InvoicePaidCb, NewBlockCb } from "../lnd/settings.js" @@ -73,9 +73,15 @@ export default class { } NewBlockHandler = async (height: number) => { - const confirmed = await this.paymentManager.CheckPendingTransactions(height) + let confirmed: (PendingTx & { confs: number; })[] + let log = getLogger({}) + try { + confirmed = await this.paymentManager.CheckPendingTransactions(height) + } catch (err: any) { + log("failed to check transactions after new block", err) + return + } await Promise.all(confirmed.map(async c => { - if (c.type === 'outgoing') { await this.storage.paymentStorage.UpdateUserTransactionPayment(c.tx.serial_id, { confs: c.confs }) } else { diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 17089d0f..b5713c76 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -28,7 +28,7 @@ interface UserOperationInfo { chain_fees?: number confs?: number } -type PendingTx = { type: 'incoming', tx: AddressReceivingTransaction } | { type: 'outgoing', tx: UserTransactionPayment } +export type PendingTx = { type: 'incoming', tx: AddressReceivingTransaction } | { type: 'outgoing', tx: UserTransactionPayment } const defaultLnurlPayMetadata = `[["text/plain", "lnurl pay to Lightning.pub"]]` const confInOne = 1000 * 1000 const confInTwo = 100 * 1000 * 1000