Skip to content

Commit

Permalink
Add blocks_til_maturity for force closed channels
Browse files Browse the repository at this point in the history
  • Loading branch information
hieblmi committed Sep 23, 2022
1 parent 9954fd5 commit 9508ad0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
13 changes: 7 additions & 6 deletions network/backend/lnd/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions network/models/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Channel struct {
Node *Node
LocalPolicy *RoutingPolicy
RemotePolicy *RoutingPolicy
BlocksTilMaturity int32
}

func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error {
Expand Down
22 changes: 13 additions & 9 deletions ui/views/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9508ad0

Please sign in to comment.