From 9be0f6a18a826a7e28e103740e4e6bd3672807a8 Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Wed, 20 Mar 2019 14:08:41 +0100 Subject: [PATCH] ft channels chartPubKey --- ui/views/channels.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ui/views/channels.go b/ui/views/channels.go index f37dd00..2074fea 100644 --- a/ui/views/channels.go +++ b/ui/views/channels.go @@ -56,12 +56,12 @@ func (c *Channels) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { } func displayChannelsHeader(v *gocui.View) { - fmt.Fprintln(v, fmt.Sprintf("%-9s %-19s %12s %12s %s", + fmt.Fprintln(v, fmt.Sprintf("%-9s %12s %12s %-64s %-19s", "status", - "id", "local", "capacity", "pub_key", + "id", )) } @@ -93,12 +93,12 @@ func (c *Channels) update(ctx context.Context) error { func (c *Channels) display() { for _, item := range c.items { - line := fmt.Sprintf("%s %s %s %12d %s", + line := fmt.Sprintf("%s %s %12d %s %s", active(item), - chartID(item), color.Cyan(fmt.Sprintf("%12d", item.LocalBalance)), item.Capacity, - item.RemotePubKey, + chartPubKey(item), + chartID(item), ) fmt.Fprintln(c.View, line) } @@ -125,3 +125,14 @@ func chartID(c *models.Channel) string { return buffer.String() } + +func chartPubKey(c *models.Channel) string { + pubkey := c.RemotePubKey + index := int(c.LocalBalance * int64(len(pubkey)) / c.Capacity) + + var buffer bytes.Buffer + buffer.WriteString(color.Cyan(pubkey[:index])) + buffer.WriteString(pubkey[index:]) + + return buffer.String() +}