better balance debug

This commit is contained in:
hatim boufnichel 2024-04-17 21:26:35 +02:00
parent c3c6a1aa34
commit 5807a2bb0b
2 changed files with 6 additions and 6 deletions

View file

@ -327,7 +327,7 @@ export default class {
channelId: c.chanId, channelId: c.chanId,
localBalanceSats: Number(c.localBalance), localBalanceSats: Number(c.localBalance),
remoteBalanceSats: Number(c.remoteBalance), remoteBalanceSats: Number(c.remoteBalance),
htlcs: c.pendingHtlcs.map(htlc => ({ incoming: htlc.incoming, amount: Number(htlc.amount) })) htlcs: c.pendingHtlcs.map(htlc => ({ incoming: htlc.incoming, amount: Number(htlc.amount), index: Number(htlc.htlcIndex), fwIndex: Number(htlc.forwardingHtlcIndex) }))
})) }))
return { confirmedBalance: Number(confirmedBalance), unconfirmedBalance: Number(unconfirmedBalance), totalBalance: Number(totalBalance), channelsBalance } return { confirmedBalance: Number(confirmedBalance), unconfirmedBalance: Number(unconfirmedBalance), totalBalance: Number(totalBalance), channelsBalance }
} }

View file

@ -36,7 +36,7 @@ export class Watchdog {
Start = async () => { Start = async () => {
const totalUsersBalance = await this.storage.paymentStorage.GetTotalUsersBalance() const totalUsersBalance = await this.storage.paymentStorage.GetTotalUsersBalance()
this.initialLndBalance = await this.getTotalLndBalance() this.initialLndBalance = await this.getTotalLndBalance(totalUsersBalance)
this.initialUsersBalance = totalUsersBalance this.initialUsersBalance = totalUsersBalance
this.enabled = true this.enabled = true
@ -48,11 +48,11 @@ export class Watchdog {
}, 1000 * 60) }, 1000 * 60)
} }
getTotalLndBalance = async () => { getTotalLndBalance = async (usersTotal: number) => {
const localLog = getLogger({ appName: "debugLndBalance" }) const localLog = getLogger({ appName: "debugLndBalancev2" })
const { confirmedBalance, channelsBalance } = await this.lnd.GetBalance() const { confirmedBalance, channelsBalance } = await this.lnd.GetBalance()
this.log(confirmedBalance, "sats in chain wallet") this.log(confirmedBalance, "sats in chain wallet")
localLog(channelsBalance) localLog({ c: channelsBalance, u: usersTotal })
let totalBalance = confirmedBalance let totalBalance = confirmedBalance
channelsBalance.forEach(c => { channelsBalance.forEach(c => {
let totalBalanceInHtlcs = 0 let totalBalanceInHtlcs = 0
@ -127,7 +127,7 @@ export class Watchdog {
} }
this.latestCheckStart = Date.now() this.latestCheckStart = Date.now()
const totalUsersBalance = await this.storage.paymentStorage.GetTotalUsersBalance() const totalUsersBalance = await this.storage.paymentStorage.GetTotalUsersBalance()
const totalLndBalance = await this.getTotalLndBalance() const totalLndBalance = await this.getTotalLndBalance(totalUsersBalance)
const deltaLnd = totalLndBalance - this.initialLndBalance const deltaLnd = totalLndBalance - this.initialLndBalance
const deltaUsers = totalUsersBalance - this.initialUsersBalance const deltaUsers = totalUsersBalance - this.initialUsersBalance
const deny = this.checkBalanceUpdate(deltaLnd, deltaUsers) const deny = this.checkBalanceUpdate(deltaLnd, deltaUsers)