@@ -410,14 +410,29 @@ func (c *ChannelsCollector) Collect(ch chan<- prometheus.Metric) {
410410
411411 // Preinitialize the map with all possible anchor state labels to avoid
412412 // "stuck" values when selecting a longer time range.
413+ limboState := anchorStateToString (lndclient .ForceCloseAnchorStateLimbo )
414+ recoveredState := anchorStateToString (
415+ lndclient .ForceCloseAnchorStateRecovered ,
416+ )
417+ lostState := anchorStateToString (lndclient .ForceCloseAnchorStateLost )
413418 forceCloseTotal := map [string ]btcutil.Amount {
414- anchorStateToString ( lndclient . ForceCloseAnchorStateLimbo ) : 0 ,
415- anchorStateToString ( lndclient . ForceCloseAnchorStateRecovered ) : 0 ,
416- anchorStateToString ( lndclient . ForceCloseAnchorStateLost ) : 0 ,
419+ limboState : 0 ,
420+ recoveredState : 0 ,
421+ lostState : 0 ,
417422 }
418423 for _ , forceClose := range pendingChannelsResp .PendingForceClose {
419- forceCloseTotal [anchorStateToString (forceClose .AnchorState )] +=
420- forceClose .RecoveredBalance
424+ // We use the anchor state names to allocate the different
425+ // balances to a human-readable state. But those balances
426+ // already include the anchor output value itself.
427+ forceCloseTotal [limboState ] += forceClose .LimboBalance
428+ forceCloseTotal [recoveredState ] += forceClose .RecoveredBalance
429+
430+ // If we actually lost the anchor output, this isn't properly
431+ // reflected in the balances, so we just need to account for the
432+ // list 330 satoshis.
433+ if forceClose .AnchorState == lndclient .ForceCloseAnchorStateLost {
434+ forceCloseTotal [lostState ] += 330
435+ }
421436 }
422437
423438 for anchorState , balance := range forceCloseTotal {
0 commit comments