loopd

package
v0.8.0-beta Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 30 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LoopMinRequiredLndVersion is the minimum required version of lnd that
	// is compatible with the current version of the loop client. Also all
	// listed build tags/subservers need to be enabled.
	LoopMinRequiredLndVersion = &verrpc.Version{
		AppMajor: 0,
		AppMinor: 10,
		AppPatch: 1,
		BuildTags: []string{
			"signrpc", "walletrpc", "chainrpc", "invoicesrpc",
		},
	}
)

Functions

func Run

func Run(rpcCfg RPCConfig) error

Run starts the loop daemon and blocks until it's shut down again.

Types

type Config

type Config struct {
	ShowVersion bool   `long:"version" description:"Display version information and exit"`
	Network     string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
	RPCListen   string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
	RESTListen  string `long:"restlisten" description:"Address to listen on for REST clients"`
	CORSOrigin  string `long:"corsorigin" description:"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty."`

	LogDir         string `long:"logdir" description:"Directory to log output."`
	MaxLogFiles    int    `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
	MaxLogFileSize int    `long:"maxlogfilesize" description:"Maximum logfile size in MB"`

	DebugLevel  string `` /* 265-byte string literal not displayed */
	MaxLSATCost uint32 `` /* 148-byte string literal not displayed */
	MaxLSATFee  uint32 `long:"maxlsatfee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an LSAT token."`

	LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."`

	Lnd *lndConfig `group:"lnd" namespace:"lnd"`

	Server *loopServerConfig `group:"server" namespace:"server"`

	View viewParameters `` /* 131-byte string literal not displayed */
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns all default values for the Config struct.

type Daemon

type Daemon struct {

	// ErrChan is an error channel that users of the Daemon struct must use
	// to detect runtime errors and also whether a shutdown is fully
	// completed.
	ErrChan chan error
	// contains filtered or unexported fields
}

Daemon is the struct that holds one instance of the loop client daemon.

func New

func New(config *Config, lisCfg *listenerCfg) *Daemon

New creates a new instance of the loop client daemon.

func (*Daemon) GetLoopInQuote

func (s *Daemon) GetLoopInQuote(ctx context.Context,
	req *looprpc.QuoteRequest) (*looprpc.InQuoteResponse, error)

GetQuote returns a quote for a swap with the provided parameters.

func (*Daemon) GetLoopInTerms

func (s *Daemon) GetLoopInTerms(ctx context.Context,
	req *looprpc.TermsRequest) (*looprpc.InTermsResponse, error)

GetTerms returns the terms that the server enforces for swaps.

func (*Daemon) GetLsatTokens

func (s *Daemon) GetLsatTokens(ctx context.Context,
	_ *looprpc.TokensRequest) (*looprpc.TokensResponse, error)

GetLsatTokens returns all tokens that are contained in the LSAT token store.

func (*Daemon) ListSwaps

func (s *Daemon) ListSwaps(_ context.Context,
	_ *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error)

ListSwaps returns a list of all currently known swaps and their current status.

func (*Daemon) LoopIn

func (s *Daemon) LoopIn(ctx context.Context,
	in *looprpc.LoopInRequest) (
	*looprpc.SwapResponse, error)

func (*Daemon) LoopOut

func (s *Daemon) LoopOut(ctx context.Context,
	in *looprpc.LoopOutRequest) (
	*looprpc.SwapResponse, error)

LoopOut initiates an loop out swap with the given parameters. The call returns after the swap has been set up with the swap server. From that point onwards, progress can be tracked via the LoopOutStatus stream that is returned from Monitor().

func (*Daemon) LoopOutQuote

func (s *Daemon) LoopOutQuote(ctx context.Context,
	req *looprpc.QuoteRequest) (*looprpc.OutQuoteResponse, error)

LoopOutQuote returns a quote for a loop out swap with the provided parameters.

func (*Daemon) LoopOutTerms

func (s *Daemon) LoopOutTerms(ctx context.Context,
	req *looprpc.TermsRequest) (*looprpc.OutTermsResponse, error)

LoopOutTerms returns the terms that the server enforces for loop out swaps.

func (*Daemon) Monitor

func (s *Daemon) Monitor(in *looprpc.MonitorRequest,
	server looprpc.SwapClient_MonitorServer) error

Monitor will return a stream of swap updates for currently active swaps.

func (*Daemon) Start

func (d *Daemon) Start() error

Start starts loopd in daemon mode. It will listen for grpc connections, execute commands and pass back swap status information.

func (*Daemon) StartAsSubserver

func (d *Daemon) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices) error

StartAsSubserver is an alternative to Start where the RPC server does not create its own gRPC server but registers to an existing one. The same goes for REST (if enabled), instead of creating an own mux and HTTP server, we register to an existing one.

func (*Daemon) Stop

func (d *Daemon) Stop()

Stop tries to gracefully shut down the daemon. A caller needs to wait for a message on the main error channel indicating that the shutdown is completed.

func (*Daemon) SwapInfo

func (s *Daemon) SwapInfo(_ context.Context,
	req *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error)

SwapInfo returns all known details about a single swap.

type RPCConfig

type RPCConfig struct {
	// RPCListener is an optional listener that if set will override the
	// daemon's gRPC settings, and make the gRPC server listen on this
	// listener.
	// Note that setting this will also disable REST.
	RPCListener net.Listener

	// LndConn is an optional connection to an lnd instance. If set it will
	// override the TCP connection created from daemon's config.
	LndConn net.Conn
}

RPCConfig holds optional options that can be used to make the loop daemon communicate on custom connections.

Jump to

Keyboard shortcuts

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