You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lntop/network/models/channel.go

105 lines
2.4 KiB
Go

5 years ago
package models
5 years ago
import (
"strings"
5 years ago
"time"
"github.com/edouardparis/lntop/logging"
)
5 years ago
const (
ChannelActive = iota + 1
ChannelInactive
ChannelOpening
ChannelClosing
ChannelForceClosing
ChannelWaitingClose
ChannelClosed
)
5 years ago
type ChannelsBalance struct {
5 years ago
Balance int64
PendingOpenBalance int64
}
5 years ago
func (m ChannelsBalance) MarshalLogObject(enc logging.ObjectEncoder) error {
5 years ago
enc.AddInt64("balance", m.Balance)
enc.AddInt64("pending_open_balance", m.PendingOpenBalance)
return nil
}
type Channel struct {
ID uint64
Status int
5 years ago
RemotePubKey string
ChannelPoint string
Capacity int64
LocalBalance int64
RemoteBalance int64
CommitFee int64
CommitWeight int64
FeePerKiloWeight int64
UnsettledBalance int64
TotalAmountSent int64
TotalAmountReceived int64
UpdatesCount uint64
CSVDelay uint32
Private bool
PendingHTLC []*HTLC
LastUpdate *time.Time
Node *Node
LocalPolicy *RoutingPolicy
RemotePolicy *RoutingPolicy
BlocksTilMaturity int32
5 years ago
}
func (m Channel) MarshalLogObject(enc logging.ObjectEncoder) error {
enc.AddUint64("id", m.ID)
enc.AddInt("status", m.Status)
5 years ago
enc.AddString("remote_pubkey", m.RemotePubKey)
enc.AddString("channel_point", m.ChannelPoint)
enc.AddInt64("capacity", m.Capacity)
enc.AddInt64("local_balance", m.LocalBalance)
enc.AddInt64("remote_balance", m.RemoteBalance)
enc.AddInt64("commit_fee", m.CommitFee)
enc.AddInt64("commit_weight", m.CommitWeight)
enc.AddInt64("unsettled_balance", m.UnsettledBalance)
enc.AddInt64("total_amount_sent", m.TotalAmountSent)
enc.AddInt64("total_amount_received", m.TotalAmountReceived)
enc.AddUint64("updates_count", m.UpdatesCount)
enc.AddBool("private", m.Private)
return nil
}
func (m Channel) ShortAlias() (alias string, forced bool) {
if m.Node != nil && m.Node.ForcedAlias != "" {
alias = m.Node.ForcedAlias
forced = true
} else if m.Node == nil || m.Node.Alias == "" {
alias = m.RemotePubKey[:24]
} else {
alias = strings.ReplaceAll(m.Node.Alias, "\ufe0f", "")
}
if len(alias) > 25 {
alias = alias[:24]
}
return
}
type ChannelUpdate struct {
}
type ChannelEdgeUpdate struct {
ChanPoints []string
}
type RoutingPolicy struct {
TimeLockDelta uint32
MinHtlc int64
2 years ago
MaxHtlc uint64
FeeBaseMsat int64
FeeRateMilliMsat int64
Disabled bool
}