Skip to content

Commit 83c65b6

Browse files
committed
lndmon: fix force closed balances
Previously the force closed balance for each anchor state was set to the recovered balance. This commit fixes that by using the correct balances for each individual state.
1 parent 52c50b6 commit 83c65b6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

collectors/channels_collector.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,24 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {
416416
anchorStateToString(lndclient.ForceCloseAnchorStateLost): 0,
417417
}
418418
for _, forceClose := range pendingChannelsResp.PendingForceClose {
419+
var balance btcutil.Amount
420+
switch forceClose.AnchorState {
421+
case lndclient.ForceCloseAnchorStateRecovered:
422+
balance = forceClose.RecoveredBalance
423+
424+
case lndclient.ForceCloseAnchorStateLimbo:
425+
balance = forceClose.LimboBalance
426+
427+
case lndclient.ForceCloseAnchorStateLost:
428+
balance = 0
429+
430+
default:
431+
c.errChan <- fmt.Errorf("Unknown anchor state: %v",
432+
forceClose.AnchorState)
433+
}
434+
419435
forceCloseTotal[anchorStateToString(forceClose.AnchorState)] +=
420-
forceClose.RecoveredBalance
436+
balance
421437
}
422438

423439
for anchorState, balance := range forceCloseTotal {

0 commit comments

Comments
 (0)