server

package
v0.0.0-...-1a0d1a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: ISC Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDcrlnd

func CheckDcrlnd(addr, tlsCertPath, macaroonPath string) error

CheckDcrlnd connects and performs sanity checks on the given dcrlnd instance.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type ChanActivityScore

type ChanActivityScore float64

ChanActivityScore holds "how much activity" a channel received through some period of time.

The basic equation for determining the "activity" score for a channel is

atoms_sent / capacity / lifetime_hours

The interpretation for this equation is that the activity score is the percentage of the channel capacity sent through the channel during its entire lifetime.

func (ChanActivityScore) ToPercent

func (s ChanActivityScore) ToPercent() float64

toPercent returns the activity score as a percentage.

type Config

type Config struct {
	ChainParams *chaincfg.Params
	RootDir     string

	// Dcrlnd Connection Options
	LNRPCHost      string
	LNTLSCertPath  string
	LNMacaroonPath string
	LNNodeAddrs    []string
	Log            slog.Logger

	// Max number of channels the underlying dcrlnd instance can have as
	// pending.
	MaxPendingChans uint

	// Policy config
	MinChanSize        uint64
	MaxChanSize        uint64
	MaxNbChannels      uint
	MinWalletBalance   dcrutil.Amount
	CloseCheckInterval time.Duration
	MinChanLifetime    time.Duration
	CreateKey          []byte
	InvoiceExpiration  time.Duration

	// ChanInvoiceFeeRate is the fee rate to charge for creating a channel.
	// in atoms/channel-size-atoms.
	ChanInvoiceFeeRate float64
}

Config holds the server config.

type ManagedChannel

type ManagedChannel struct {
	// Lifetime of the channel since it has opened.
	Lifetime       time.Duration
	ChanPoint      string
	Sid            lnwire.ShortChannelID
	RemotePubkey   string
	Capacity       dcrutil.Amount
	LocalBalance   dcrutil.Amount
	RemoteBalance  dcrutil.Amount
	TotalAtomsSent dcrutil.Amount

	// HasMinLifetime is true when this channel has the minimum lifetime
	// required to be eligible for closing.
	HasMinLifetime bool

	// Score of the channel (activity % within its lifetime).
	Score ChanActivityScore

	// WillClose whether this channel is likely to be closed in the next
	// round of management.
	WillClose bool
}

ManagedChannel is information about channels managed by the LP.

type ManagementInfo

type ManagementInfo struct {
	// WalletBalance is the amount available (confirmed + unconfirmed) in
	// the on-chain wallet.
	WalletBalance dcrutil.Amount

	// LimboBalance is the amount that is pending to be reclaimed in
	// already closed channels.
	LimboBalance dcrutil.Amount

	// TotalBalance available to open channels (both confirmed and pending
	// to be reclaimed).
	TotalBalance dcrutil.Amount

	// MinWalletBalance minimum amount of funds that must be available to
	// open new channels. When the total balance is lower than this amount,
	// channels will start to be closed.
	MinWalletBalance dcrutil.Amount

	// BlockHeight is the current block height of the wallet.
	BlockHeight uint32

	// Channels is the list of channels managed by the LP server.
	Channels []ManagedChannel

	// UnmanagedChannels are channels that are NOT eligible for closing by
	// the LP server.
	UnmanagedChannels []UnmanagedChannel

	// NeedsManagement is true when the channels need to be managed to
	// reclaim some funds.
	NeedsManagement bool

	// Reclaimed is the (approximate) amount that will be reclaimed after
	// closing some channels. This does not take into account various
	// transaction fees that will need to be paid.
	Reclaimed dcrutil.Amount
}

ManagementInfo is the full set of information taken into account when managing channels.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a server instance.

func New

func New(cfg *Config) (*Server, error)

New creates a new server instance.

func (*Server) CreateInvoice

func (s *Server) CreateInvoice(ctx context.Context, node rpc.NodeID, chanSize uint64) (string, error)

CreateInvoice creates an invoice that, once paid, will trigger the underlying node to open a channel back to the specified client.

func (*Server) FetchManagedChannels

func (s *Server) FetchManagedChannels(ctx context.Context) (res ManagementInfo, err error)

FetchManagedChannels returns the list of channels managed by the server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts all service goroutines and blocks until the passed context is canceled.

type UnmanagedChannel

type UnmanagedChannel struct {
	ChanPoint     string
	Sid           lnwire.ShortChannelID
	Capacity      dcrutil.Amount
	LocalBalance  dcrutil.Amount
	RemoteBalance dcrutil.Amount
}

UnmanagedChannel is information about channels NOT managed by the LP.

type V1Handler

type V1Handler struct {
	*Server
}

func NewV1Handler

func NewV1Handler(s *Server, router *mux.Router) *V1Handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL