fix event log
This commit is contained in:
parent
a8425c3afa
commit
780d357c0b
2 changed files with 30 additions and 2 deletions
|
|
@ -144,6 +144,22 @@ export class LiquidityProvider {
|
|||
return res
|
||||
}
|
||||
|
||||
GetOperations = async () => {
|
||||
if (this.latestMaxWithdrawable === null) {
|
||||
throw new Error("liquidity provider is not ready yet")
|
||||
}
|
||||
const res = await this.client.GetUserOperations({
|
||||
latestIncomingInvoice: 0, latestOutgoingInvoice: 0,
|
||||
latestIncomingTx: 0, latestOutgoingTx: 0, latestIncomingUserToUserPayment: 0,
|
||||
latestOutgoingUserToUserPayment: 0, max_size: 200
|
||||
})
|
||||
if (res.status === 'ERROR') {
|
||||
this.log("error getting operations", res.reason)
|
||||
throw new Error(res.reason)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
setNostrInfo = ({ clientId, myPub }: { myPub: string, clientId: string }) => {
|
||||
this.clientId = clientId
|
||||
this.myPub = myPub
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import LND from "../lnd/lnd.js"
|
|||
import { LoggedEvent } from '../storage/eventsLog.js'
|
||||
import { Invoice, Payment } from '../../../proto/lnd/lightning';
|
||||
import { getLogger } from '../helpers/logger.js';
|
||||
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
||||
const LN_INVOICE_REGEX = /^(lightning:)?(lnbc|lntb)[0-9a-zA-Z]+$/;
|
||||
const BITCOIN_ADDRESS_REGEX = /^(bitcoin:)?([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{39,59})$/;
|
||||
type UniqueDecrementReasons = 'ban'
|
||||
|
|
@ -17,6 +18,8 @@ export default class SanityChecker {
|
|||
events: LoggedEvent[] = []
|
||||
invoices: Invoice[] = []
|
||||
payments: Payment[] = []
|
||||
providerInvoices: Types.UserOperation[] = []
|
||||
providerPayments: Types.UserOperation[] = []
|
||||
incrementSources: Record<string, boolean> = {}
|
||||
decrementSources: Record<string, boolean> = {}
|
||||
decrementEvents: Record<string, { userId: string, refund: number, failure: boolean }> = {}
|
||||
|
|
@ -110,7 +113,10 @@ export default class SanityChecker {
|
|||
if (!entry.internal) {
|
||||
const lndEntry = this.payments.find(i => i.paymentRequest === invoice)
|
||||
if (!lndEntry) {
|
||||
throw new Error("payment not found in lnd for invoice " + invoice)
|
||||
const providerEntry = this.providerPayments.find(i => i.identifier === invoice)
|
||||
if (!providerEntry) {
|
||||
throw new Error("payment not found in lnd for invoice " + invoice)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +192,10 @@ export default class SanityChecker {
|
|||
if (!entry.internal) {
|
||||
const entry = this.invoices.find(i => i.paymentRequest === invoice)
|
||||
if (!entry) {
|
||||
throw new Error("invoice not found in lnd " + invoice)
|
||||
const providerEntry = this.providerInvoices.find(i => i.identifier === invoice)
|
||||
if (!providerEntry) {
|
||||
throw new Error("invoice not found in lnd " + invoice)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -227,6 +236,9 @@ 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
|
||||
this.incrementSources = {}
|
||||
this.decrementSources = {}
|
||||
this.users = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue