sub pending balance in htlcs
This commit is contained in:
parent
a95becbfb6
commit
79fde739b8
3 changed files with 15 additions and 3 deletions
|
|
@ -326,7 +326,8 @@ export default class {
|
||||||
const channelsBalance = response.channels.map(c => ({
|
const channelsBalance = response.channels.map(c => ({
|
||||||
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) }))
|
||||||
}))
|
}))
|
||||||
return { confirmedBalance: Number(confirmedBalance), unconfirmedBalance: Number(unconfirmedBalance), totalBalance: Number(totalBalance), channelsBalance }
|
return { confirmedBalance: Number(confirmedBalance), unconfirmedBalance: Number(unconfirmedBalance), totalBalance: Number(totalBalance), channelsBalance }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ export type BalanceInfo = {
|
||||||
channelId: string;
|
channelId: string;
|
||||||
localBalanceSats: number;
|
localBalanceSats: number;
|
||||||
remoteBalanceSats: number;
|
remoteBalanceSats: number;
|
||||||
|
htlcs: { incoming: boolean, amount: number }[]
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,18 @@ export class Watchdog {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTotalLndBalance = async () => {
|
getTotalLndBalance = async () => {
|
||||||
const { channelsBalance, confirmedBalance } = await this.lnd.GetBalance()
|
const { confirmedBalance, channelsBalance } = await this.lnd.GetBalance()
|
||||||
return confirmedBalance + channelsBalance.reduce((acc, { localBalanceSats }) => acc + localBalanceSats, 0)
|
let total = confirmedBalance
|
||||||
|
channelsBalance.forEach(c => {
|
||||||
|
let outgoingSats = 0
|
||||||
|
c.htlcs.forEach(htlc => {
|
||||||
|
if (!htlc.incoming) {
|
||||||
|
outgoingSats += Number(htlc.amount)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
total += Number(c.localBalanceSats) - outgoingSats
|
||||||
|
})
|
||||||
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBalanceUpdate = (deltaLnd: number, deltaUsers: number) => {
|
checkBalanceUpdate = (deltaLnd: number, deltaUsers: number) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue