From 9508ad06d9ebeee90aa2536ddb2f078adefaf32c Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Fri, 23 Sep 2022 11:16:50 -0400 Subject: [PATCH] Add blocks_til_maturity for force closed channels --- network/backend/lnd/proto.go | 13 +++++++------ network/models/channel.go | 1 + ui/views/channel.go | 22 +++++++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/network/backend/lnd/proto.go b/network/backend/lnd/proto.go index 1ece758..228d3e0 100644 --- a/network/backend/lnd/proto.go +++ b/network/backend/lnd/proto.go @@ -170,12 +170,13 @@ func closingChannelProtoToChannel(c *lnrpc.PendingChannelsResponse_ClosedChannel func forceClosingChannelProtoToChannel(c *lnrpc.PendingChannelsResponse_ForceClosedChannel) *models.Channel { return &models.Channel{ - Status: models.ChannelClosing, - RemotePubKey: c.Channel.RemoteNodePub, - Capacity: c.Channel.Capacity, - LocalBalance: c.Channel.LocalBalance, - RemoteBalance: c.Channel.RemoteBalance, - ChannelPoint: c.Channel.ChannelPoint, + Status: models.ChannelForceClosing, + RemotePubKey: c.Channel.RemoteNodePub, + Capacity: c.Channel.Capacity, + LocalBalance: c.Channel.LocalBalance, + RemoteBalance: c.Channel.RemoteBalance, + ChannelPoint: c.Channel.ChannelPoint, + BlocksTilMaturity: c.BlocksTilMaturity, } } diff --git a/network/models/channel.go b/network/models/channel.go index 4a3e1f2..b819d12 100644 --- a/network/models/channel.go +++ b/network/models/channel.go @@ -51,6 +51,7 @@ type Channel struct { Node *Node LocalPolicy *RoutingPolicy RemotePolicy *RoutingPolicy + BlocksTilMaturity int32 } func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error { diff --git a/ui/views/channel.go b/ui/views/channel.go index 3a58bf2..24ef04c 100644 --- a/ui/views/channel.go +++ b/ui/views/channel.go @@ -7,7 +7,7 @@ import ( "golang.org/x/text/language" "golang.org/x/text/message" - netModels "github.com/edouardparis/lntop/network/models" + netmodels "github.com/edouardparis/lntop/network/models" "github.com/edouardparis/lntop/ui/color" "github.com/edouardparis/lntop/ui/models" ) @@ -119,7 +119,7 @@ func (c Channel) Delete(g *gocui.Gui) error { return g.DeleteView(CHANNEL_FOOTER) } -func printPolicy(v *gocui.View, p *message.Printer, policy *netModels.RoutingPolicy, outgoing bool) { +func printPolicy(v *gocui.View, p *message.Printer, policy *netmodels.RoutingPolicy, outgoing bool) { green := color.Green() cyan := color.Cyan() red := color.Red() @@ -186,22 +186,26 @@ func (c *Channel) display() { cyan := color.Cyan() fmt.Fprintln(v, green(" [ Channel ]")) fmt.Fprintf(v, "%s %s\n", - cyan(" Status:"), status(channel)) + cyan(" Status:"), status(channel)) + if channel.Status == netmodels.ChannelForceClosing { + fmt.Fprintf(v, "%s %d\n", + cyan("Blocks til maturity:"), channel.BlocksTilMaturity) + } fmt.Fprintf(v, "%s %d (%s)\n", - cyan(" ID:"), channel.ID, ToScid(channel.ID)) + cyan(" ID:"), channel.ID, ToScid(channel.ID)) fmt.Fprintf(v, "%s %s\n", - cyan(" Capacity:"), formatAmount(channel.Capacity)) + cyan(" Capacity:"), formatAmount(channel.Capacity)) fmt.Fprintf(v, "%s %s\n", - cyan(" Local Balance:"), formatAmount(channel.LocalBalance)) + cyan(" Local Balance:"), formatAmount(channel.LocalBalance)) fmt.Fprintf(v, "%s %s\n", - cyan(" Remote Balance:"), formatAmount(channel.RemoteBalance)) + cyan(" Remote Balance:"), formatAmount(channel.RemoteBalance)) fmt.Fprintf(v, "%s %s\n", - cyan(" Channel Point:"), channel.ChannelPoint) + cyan(" Channel Point:"), channel.ChannelPoint) fmt.Fprintln(v, "") + fmt.Fprintln(v, green(" [ Node ]")) fmt.Fprintf(v, "%s %s\n", cyan(" PubKey:"), channel.RemotePubKey) - if channel.Node != nil { alias, forced := channel.ShortAlias() if forced {