fix crash

This commit is contained in:
boufni95 2023-12-02 13:47:55 +01:00
parent 8f36ae003a
commit 2705d6957e
2 changed files with 10 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js'
import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js' import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js'
import ProductManager from './productManager.js' import ProductManager from './productManager.js'
import ApplicationManager from './applicationManager.js' import ApplicationManager from './applicationManager.js'
import PaymentManager from './paymentManager.js' import PaymentManager, { PendingTx } from './paymentManager.js'
import { MainSettings } from './settings.js' import { MainSettings } from './settings.js'
import NewLightningHandler, { LoadLndSettingsFromEnv, LightningHandler } from "../lnd/index.js" import NewLightningHandler, { LoadLndSettingsFromEnv, LightningHandler } from "../lnd/index.js"
import { AddressPaidCb, InvoicePaidCb, NewBlockCb } from "../lnd/settings.js" import { AddressPaidCb, InvoicePaidCb, NewBlockCb } from "../lnd/settings.js"
@ -73,9 +73,15 @@ export default class {
} }
NewBlockHandler = async (height: number) => { 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 => { await Promise.all(confirmed.map(async c => {
if (c.type === 'outgoing') { if (c.type === 'outgoing') {
await this.storage.paymentStorage.UpdateUserTransactionPayment(c.tx.serial_id, { confs: c.confs }) await this.storage.paymentStorage.UpdateUserTransactionPayment(c.tx.serial_id, { confs: c.confs })
} else { } else {

View file

@ -28,7 +28,7 @@ interface UserOperationInfo {
chain_fees?: number chain_fees?: number
confs?: 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 defaultLnurlPayMetadata = `[["text/plain", "lnurl pay to Lightning.pub"]]`
const confInOne = 1000 * 1000 const confInOne = 1000 * 1000
const confInTwo = 100 * 1000 * 1000 const confInTwo = 100 * 1000 * 1000