From 3a5a03fa49a658424918caf93bda19ce3eb838e7 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 17 May 2021 09:36:05 +0200 Subject: [PATCH] rpcserver: add nil check to policy ordering Fixes #5301. This was introduced with #5295. Since either policies can be nil, we need to always check that first. --- rpcserver.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 8c7f1bee..114ccb11 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -5166,13 +5166,8 @@ func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo, // Make sure the policies match the node they belong to. c1 should point // to the policy for NodeKey1, and c2 for NodeKey2. - if c1.ChannelFlags&lnwire.ChanUpdateDirection == 1 { - c2, c1 = c1, c2 - } - - // Order the edges by increasing pubkey. - if bytes.Compare(edgeInfo.NodeKey2Bytes[:], - edgeInfo.NodeKey1Bytes[:]) < 0 { + if c1 != nil && c1.ChannelFlags&lnwire.ChanUpdateDirection == 1 || + c2 != nil && c2.ChannelFlags&lnwire.ChanUpdateDirection == 0 { c2, c1 = c1, c2 }