ft channels chartPubKey

pull/1/head
Edouard Paris 5 years ago
parent 75c67d13af
commit 9be0f6a18a

@ -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()
}

Loading…
Cancel
Save