From 9a75400295ac23d1e6ffb57bdbaf74db7725b6f4 Mon Sep 17 00:00:00 2001 From: ziggie Date: Sun, 6 Jul 2025 09:28:53 +0200 Subject: [PATCH] multi: add logs to debug potential payment sending issue --- htlcswitch/switch.go | 3 +++ routing/bandwidth.go | 5 ++++- routing/pathfind.go | 20 ++++++++++++++++++++ routing/unified_edges.go | 3 ++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 38b308b69..0d85805b9 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -2229,6 +2229,9 @@ func (s *Switch) GetLinkByShortID(chanID lnwire.ShortChannelID) (ChannelLink, func (s *Switch) getLinkByShortID(chanID lnwire.ShortChannelID) (ChannelLink, error) { link, ok := s.forwardingIndex[chanID] if !ok { + log.Debugf("Link not found in forwarding index using "+ + "chanID=%v", chanID) + return nil, ErrChannelLinkNotFound } diff --git a/routing/bandwidth.go b/routing/bandwidth.go index e9cfb5968..31466e78b 100644 --- a/routing/bandwidth.go +++ b/routing/bandwidth.go @@ -91,7 +91,10 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID, if err != nil { // If the link isn't online, then we'll report that it has // zero bandwidth. - log.Warnf("ShortChannelID=%v: link not found: %v", cid, err) + log.Warnf("ShortChannelID=%v: link not found when "+ + "determining bandwidth for local channel=%v, "+ + "reporting 0 bandwidth", cid, err) + return 0 } diff --git a/routing/pathfind.go b/routing/pathfind.go index f489173f9..91bec3861 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -514,7 +514,18 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{}, var max, total lnwire.MilliSatoshi cb := func(channel *graphdb.DirectedChannel) error { + shortID := lnwire.NewShortChanIDFromInt(channel.ChannelID) + + // This log line is needed to debug issues in case we do not + // have a channel in our graph for some reason when evaluating + // the local balance. Otherwise we could not tell whether all + // channels are being evaluated. + log.Tracef("Evaluating channel %v for local balance", shortID) + if !channel.OutPolicySet { + log.Debugf("ShortChannelID=%v: has no out policy set, "+ + "skipping", shortID) + return nil } @@ -536,6 +547,12 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{}, // we've already queried the bandwidth hints. if !ok { bandwidth = lnwire.NewMSatFromSatoshis(channel.Capacity) + + log.Warnf("ShortChannelID=%v: not found in the local "+ + "channels map of the bandwidth manager, "+ + "using channel capacity=%v as bandwidth for "+ + "this channel", shortID, bandwidth, + ) } if bandwidth > max { @@ -545,6 +562,9 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{}, var overflow bool total, overflow = overflowSafeAdd(total, bandwidth) if overflow { + log.Warnf("ShortChannelID=%v: overflow detected, "+ + "setting total to max value", shortID) + // If the current total and the bandwidth would // overflow the maximum value, we set the total to the // maximum value. Which is more milli-satoshis than are diff --git a/routing/unified_edges.go b/routing/unified_edges.go index 9e28a53c0..bf2f75dbf 100644 --- a/routing/unified_edges.go +++ b/routing/unified_edges.go @@ -280,8 +280,9 @@ func (u *edgeUnifier) getEdgeLocal(netAmtReceived lnwire.MilliSatoshi, edge.policy.ChannelID, amt, ) if !ok { - log.Debugf("Cannot get bandwidth for edge %v, use max "+ + log.Warnf("Cannot get bandwidth for edge %v, use max "+ "instead", edge.policy.ChannelID) + bandwidth = lnwire.MaxMilliSatoshi }