Skip to content

Commit b01437d

Browse files
committed
rpc: fix policy order for GetNodeInfo
GetNodeInfo retrieves the policies for every edge the node belongs to. When these policies are retrieved from the database, they're returned in the following order: the first policy is the outgoing policy from the node, and the second is the incoming policy to the node. This ordering is not consistent with the ordering we have within our other RPCs like GetChanInfo and DescribeGraph, where policies are sorted based on the smaller public key of the nodes within an edge. We fix this by maintaining the same order as our other RPCs.
1 parent c0acdd8 commit b01437d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rpcserver.go

+6
Original file line numberDiff line numberDiff line change
@@ -5155,6 +5155,12 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
51555155
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
51565156
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
51575157

5158+
// Make sure the policies match the node they belong to. c1 should point
5159+
// to the policy for NodeKey1, and c2 for NodeKey2.
5160+
if c1.ChannelFlags&lnwire.ChanUpdateDirection == 1 {
5161+
c2, c1 = c1, c2
5162+
}
5163+
51585164
// Order the edges by increasing pubkey.
51595165
if bytes.Compare(edgeInfo.NodeKey2Bytes[:],
51605166
edgeInfo.NodeKey1Bytes[:]) < 0 {

0 commit comments

Comments
 (0)