Documentation ¶
Index ¶
- Constants
- Variables
- func Run(rpcCfg RPCConfig) error
- func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor)
- func ToClientReservations(res []*reservation.Reservation) []*looprpc.ClientReservation
- func Validate(cfg *Config) error
- type Config
- type Daemon
- func (s *Daemon) AbandonSwap(ctx context.Context, req *looprpc.AbandonSwapRequest) (*looprpc.AbandonSwapResponse, error)
- func (s *Daemon) FetchL402Token(ctx context.Context, _ *looprpc.FetchL402TokenRequest) (*looprpc.FetchL402TokenResponse, error)
- func (s *Daemon) GetInfo(ctx context.Context, _ *looprpc.GetInfoRequest) (*looprpc.GetInfoResponse, error)
- func (s *Daemon) GetL402Tokens(ctx context.Context, _ *looprpc.TokensRequest) (*looprpc.TokensResponse, error)
- func (s *Daemon) GetLiquidityParams(_ context.Context, _ *looprpc.GetLiquidityParamsRequest) (*looprpc.LiquidityParameters, error)
- func (s *Daemon) GetLoopInQuote(ctx context.Context, req *looprpc.QuoteRequest) (*looprpc.InQuoteResponse, error)
- func (s *Daemon) GetLoopInTerms(ctx context.Context, _ *looprpc.TermsRequest) (*looprpc.InTermsResponse, error)
- func (s *Daemon) GetLsatTokens(ctx context.Context, req *looprpc.TokensRequest) (*looprpc.TokensResponse, error)
- func (s *Daemon) GetStaticAddressSummary(ctx context.Context, _ *looprpc.StaticAddressSummaryRequest) (*looprpc.StaticAddressSummaryResponse, error)
- func (s *Daemon) InstantOut(ctx context.Context, req *looprpc.InstantOutRequest) (*looprpc.InstantOutResponse, error)
- func (s *Daemon) InstantOutQuote(ctx context.Context, req *looprpc.InstantOutQuoteRequest) (*looprpc.InstantOutQuoteResponse, error)
- func (s *Daemon) ListInstantOuts(ctx context.Context, _ *looprpc.ListInstantOutsRequest) (*looprpc.ListInstantOutsResponse, error)
- func (s *Daemon) ListReservations(ctx context.Context, _ *looprpc.ListReservationsRequest) (*looprpc.ListReservationsResponse, error)
- func (s *Daemon) ListStaticAddressDeposits(ctx context.Context, req *looprpc.ListStaticAddressDepositsRequest) (*looprpc.ListStaticAddressDepositsResponse, error)
- func (s *Daemon) ListStaticAddressSwaps(ctx context.Context, _ *looprpc.ListStaticAddressSwapsRequest) (*looprpc.ListStaticAddressSwapsResponse, error)
- func (s *Daemon) ListSwaps(_ context.Context, req *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error)
- func (s *Daemon) ListUnspentDeposits(ctx context.Context, req *looprpc.ListUnspentDepositsRequest) (*looprpc.ListUnspentDepositsResponse, error)
- func (s *Daemon) LoopIn(ctx context.Context, in *looprpc.LoopInRequest) (*looprpc.SwapResponse, error)
- func (s *Daemon) LoopOut(ctx context.Context, in *looprpc.LoopOutRequest) (*looprpc.SwapResponse, error)
- func (s *Daemon) LoopOutQuote(ctx context.Context, req *looprpc.QuoteRequest) (*looprpc.OutQuoteResponse, error)
- func (s *Daemon) LoopOutTerms(ctx context.Context, _ *looprpc.TermsRequest) (*looprpc.OutTermsResponse, error)
- func (s *Daemon) Monitor(in *looprpc.MonitorRequest, server looprpc.SwapClient_MonitorServer) error
- func (s *Daemon) NewStaticAddress(ctx context.Context, _ *looprpc.NewStaticAddressRequest) (*looprpc.NewStaticAddressResponse, error)
- func (s *Daemon) Probe(ctx context.Context, req *looprpc.ProbeRequest) (*looprpc.ProbeResponse, error)
- func (s *Daemon) SetLiquidityParams(ctx context.Context, in *looprpc.SetLiquidityParamsRequest) (*looprpc.SetLiquidityParamsResponse, error)
- func (d *Daemon) Start() error
- func (d *Daemon) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices, withMacaroonService bool) error
- func (s *Daemon) StaticAddressLoopIn(ctx context.Context, in *looprpc.StaticAddressLoopInRequest) (*looprpc.StaticAddressLoopInResponse, error)
- func (d *Daemon) Stop()
- func (s *Daemon) SuggestSwaps(ctx context.Context, _ *looprpc.SuggestSwapsRequest) (*looprpc.SuggestSwapsResponse, error)
- func (s *Daemon) SwapInfo(_ context.Context, req *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error)
- func (d *Daemon) ValidateMacaroon(ctx context.Context, requiredPermissions []bakery.Op, fullMethod string) error
- func (s *Daemon) WithdrawDeposits(ctx context.Context, req *looprpc.WithdrawDepositsRequest) (*looprpc.WithdrawDepositsResponse, error)
- type ListenerCfg
- type RPCConfig
Constants ¶
const Subsystem = "LOOPD"
Variables ¶
var ( // LoopDirBase is the default main directory where loop stores its data. LoopDirBase = btcutil.AppDataDir("loop", false) // DefaultNetwork is the default bitcoin network loop runs on. DefaultNetwork = "mainnet" // DefaultTLSCertFilename is the default file name for the autogenerated // TLS certificate. DefaultTLSCertFilename = "tls.cert" // DefaultTLSKeyFilename is the default file name for the autogenerated // TLS key. DefaultTLSKeyFilename = "tls.key" // DatabaseBackendSqlite is the name of the SQLite database backend. DatabaseBackendSqlite = "sqlite" // DatabaseBackendPostgres is the name of the Postgres database backend. DatabaseBackendPostgres = "postgres" // DefaultLndMacaroonPath is the default mainnet admin macaroon path of // LND. DefaultLndMacaroonPath = filepath.Join( btcutil.AppDataDir("lnd", false), "data", "chain", "bitcoin", DefaultNetwork, defaultLndMacaroon, ) // DefaultLndRPCTimeout is the default timeout to use when communicating // with lnd. DefaultLndRPCTimeout = time.Minute // DefaultTLSCertPath is the default full path of the autogenerated TLS // certificate. DefaultTLSCertPath = filepath.Join( LoopDirBase, DefaultNetwork, DefaultTLSCertFilename, ) // DefaultTLSKeyPath is the default full path of the autogenerated TLS // key. DefaultTLSKeyPath = filepath.Join( LoopDirBase, DefaultNetwork, DefaultTLSKeyFilename, ) // DefaultMacaroonFilename is the default file name for the // autogenerated loop macaroon. DefaultMacaroonFilename = "loop.macaroon" // DefaultMacaroonPath is the default full path of the base loop // macaroon. DefaultMacaroonPath = filepath.Join( LoopDirBase, DefaultNetwork, DefaultMacaroonFilename, ) // DefaultAutogenValidity is the default validity of a self-signed // certificate in number of days. DefaultAutogenValidity = 365 * 24 * time.Hour )
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: 17, AppPatch: 0, BuildTags: []string{ "signrpc", "walletrpc", "chainrpc", "invoicesrpc", }, } )
Functions ¶
func SetupLoggers ¶
func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor)
SetupLoggers initializes all package-global logger variables.
func ToClientReservations ¶
func ToClientReservations( res []*reservation.Reservation) []*looprpc.ClientReservation
ToClientReservations converts a slice of server reservations to a slice of client reservations.
Types ¶
type Config ¶
type Config struct { ShowVersion bool `long:"version" description:"Display version information and exit"` Network string `` /* 129-byte string literal not displayed */ 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."` LoopDir string `` /* 166-byte string literal not displayed */ ConfigFile string `long:"configfile" description:"Path to configuration file."` DataDir string `long:"datadir" description:"Directory for loopdb."` DatabaseBackend string `` /* 134-byte string literal not displayed */ Sqlite *loopdb.SqliteConfig `group:"sqlite" namespace:"sqlite"` Postgres *loopdb.PostgresConfig `group:"postgres" namespace:"postgres"` TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for loop's RPC and REST services."` TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for loop's RPC and REST services."` TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra IP to the generated certificate."` TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate."` TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed."` TLSDisableAutofill bool `` /* 174-byte string literal not displayed */ TLSValidity time.Duration `long:"tlsvalidity" description:"Loop's TLS certificate validity period in days. Defaults to 8760h (1 year)"` MacaroonPath string `long:"macaroonpath" description:"Path to write the macaroon for loop's RPC and REST services if it doesn't exist."` 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 `long:"maxlsatcost" hidden:"true"` MaxLSATFee uint32 `long:"maxlsatfee" hidden:"true"` MaxL402Cost uint32 `` /* 148-byte string literal not displayed */ MaxL402Fee uint32 `long:"maxl402fee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an L402 token."` LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."` TotalPaymentTimeout time.Duration `long:"totalpaymenttimeout" description:"The timeout to use for off-chain payments."` MaxPaymentRetries int `long:"maxpaymentretries" description:"The maximum number of times an off-chain payment may be retried."` MaxStaticAddrHtlcFeePercentage float64 `long:"maxstaticaddrhtlcfeepercentage" description:"The maximum fee percentage that the server can charge for the htlc tx."` MaxStaticAddrHtlcBackupFeePercentage float64 `` /* 327-byte string literal not displayed */ EnableExperimental bool `long:"experimental" description:"Enable experimental features: reservations"` MigrationRPCBatchSize int `long:"migrationrpcbatchsize" description:"The RPC batch size to use during migrations."` 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) AbandonSwap ¶
func (s *Daemon) AbandonSwap(ctx context.Context, req *looprpc.AbandonSwapRequest) (*looprpc.AbandonSwapResponse, error)
AbandonSwap requests the server to abandon a swap with the given hash.
func (*Daemon) FetchL402Token ¶
func (s *Daemon) FetchL402Token(ctx context.Context, _ *looprpc.FetchL402TokenRequest) (*looprpc.FetchL402TokenResponse, error)
FetchL402Token fetches a L402 Token from the server. This is required to listen for server notifications such as reservations. If a token is already in the local L402, nothing will happen.
func (*Daemon) GetInfo ¶
func (s *Daemon) GetInfo(ctx context.Context, _ *looprpc.GetInfoRequest) (*looprpc.GetInfoResponse, error)
GetInfo returns basic information about the loop daemon and details to swaps from the swap store.
func (*Daemon) GetL402Tokens ¶
func (s *Daemon) GetL402Tokens(ctx context.Context, _ *looprpc.TokensRequest) (*looprpc.TokensResponse, error)
GetL402Tokens returns all tokens that are contained in the L402 token store.
func (*Daemon) GetLiquidityParams ¶
func (s *Daemon) GetLiquidityParams(_ context.Context, _ *looprpc.GetLiquidityParamsRequest) (*looprpc.LiquidityParameters, error)
GetLiquidityParams gets our current liquidity manager's parameters.
func (*Daemon) GetLoopInQuote ¶
func (s *Daemon) GetLoopInQuote(ctx context.Context, req *looprpc.QuoteRequest) (*looprpc.InQuoteResponse, error)
GetLoopInQuote returns a quote for a swap with the provided parameters.
func (*Daemon) GetLoopInTerms ¶
func (s *Daemon) GetLoopInTerms(ctx context.Context, _ *looprpc.TermsRequest) (*looprpc.InTermsResponse, error)
GetLoopInTerms returns the terms that the server enforces for swaps.
func (*Daemon) GetLsatTokens ¶
func (s *Daemon) GetLsatTokens(ctx context.Context, req *looprpc.TokensRequest) (*looprpc.TokensResponse, error)
GetLsatTokens returns all tokens that are contained in the L402 token store. Deprecated: use GetL402Tokens. This API is provided to maintain backward compatibility with gRPC clients (e.g. `loop listauth`, Terminal Web, RTL). Type LsatToken used by GetLsatTokens in the past was renamed to L402Token, but this does not affect binary encoding, so we can use type L402Token here.
func (*Daemon) GetStaticAddressSummary ¶
func (s *Daemon) GetStaticAddressSummary(ctx context.Context, _ *looprpc.StaticAddressSummaryRequest) ( *looprpc.StaticAddressSummaryResponse, error)
GetStaticAddressSummary returns a summary static address related information. Amongst deposits and withdrawals and their total values it also includes a list of detailed deposit information filtered by their state.
func (*Daemon) InstantOut ¶
func (s *Daemon) InstantOut(ctx context.Context, req *looprpc.InstantOutRequest) (*looprpc.InstantOutResponse, error)
InstantOut initiates an instant out swap.
func (*Daemon) InstantOutQuote ¶
func (s *Daemon) InstantOutQuote(ctx context.Context, req *looprpc.InstantOutQuoteRequest) ( *looprpc.InstantOutQuoteResponse, error)
InstantOutQuote returns a quote for an instant out swap with the provided parameters.
func (*Daemon) ListInstantOuts ¶
func (s *Daemon) ListInstantOuts(ctx context.Context, _ *looprpc.ListInstantOutsRequest) ( *looprpc.ListInstantOutsResponse, error)
ListInstantOuts returns a list of all currently known instant out swaps and their current status.
func (*Daemon) ListReservations ¶
func (s *Daemon) ListReservations(ctx context.Context, _ *looprpc.ListReservationsRequest) ( *looprpc.ListReservationsResponse, error)
ListReservations lists all existing reservations the client has ever made.
func (*Daemon) ListStaticAddressDeposits ¶
func (s *Daemon) ListStaticAddressDeposits(ctx context.Context, req *looprpc.ListStaticAddressDepositsRequest) ( *looprpc.ListStaticAddressDepositsResponse, error)
ListStaticAddressDeposits returns a list of all sufficiently confirmed deposits behind the static address and displays properties like value, state or blocks til expiry.
func (*Daemon) ListStaticAddressSwaps ¶
func (s *Daemon) ListStaticAddressSwaps(ctx context.Context, _ *looprpc.ListStaticAddressSwapsRequest) ( *looprpc.ListStaticAddressSwapsResponse, error)
ListStaticAddressSwaps returns a list of all swaps that are currently pending or previously succeeded.
func (*Daemon) ListSwaps ¶
func (s *Daemon) ListSwaps(_ context.Context, req *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error)
ListSwaps returns a list of all currently known swaps and their current status.
func (*Daemon) ListUnspentDeposits ¶
func (s *Daemon) ListUnspentDeposits(ctx context.Context, req *looprpc.ListUnspentDepositsRequest) ( *looprpc.ListUnspentDepositsResponse, error)
ListUnspentDeposits returns a list of utxos behind the static address.
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 a 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, _ *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) NewStaticAddress ¶
func (s *Daemon) NewStaticAddress(ctx context.Context, _ *looprpc.NewStaticAddressRequest) ( *looprpc.NewStaticAddressResponse, error)
NewStaticAddress is the rpc endpoint for loop clients to request a new static address.
func (*Daemon) Probe ¶
func (s *Daemon) Probe(ctx context.Context, req *looprpc.ProbeRequest) (*looprpc.ProbeResponse, error)
Probe requests the server to probe the client's node to test inbound liquidity.
func (*Daemon) SetLiquidityParams ¶
func (s *Daemon) SetLiquidityParams(ctx context.Context, in *looprpc.SetLiquidityParamsRequest) (*looprpc.SetLiquidityParamsResponse, error)
SetLiquidityParams attempts to set our current liquidity manager's parameters.
func (*Daemon) Start ¶
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, withMacaroonService bool) 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) StaticAddressLoopIn ¶
func (s *Daemon) StaticAddressLoopIn(ctx context.Context, in *looprpc.StaticAddressLoopInRequest) ( *looprpc.StaticAddressLoopInResponse, error)
StaticAddressLoopIn initiates a loop-in request using static address deposits.
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) SuggestSwaps ¶
func (s *Daemon) SuggestSwaps(ctx context.Context, _ *looprpc.SuggestSwapsRequest) (*looprpc.SuggestSwapsResponse, error)
SuggestSwaps provides a list of suggested swaps based on lnd's current channel balances and rules set by the liquidity manager.
func (*Daemon) SwapInfo ¶
func (s *Daemon) SwapInfo(_ context.Context, req *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error)
SwapInfo returns all known details about a single swap.
func (*Daemon) ValidateMacaroon ¶
func (d *Daemon) ValidateMacaroon(ctx context.Context, requiredPermissions []bakery.Op, fullMethod string) error
ValidateMacaroon extracts the macaroon from the context's gRPC metadata, checks its signature, makes sure all specified permissions for the called method are contained within and finally ensures all caveat conditions are met. A non-nil error is returned if any of the checks fail. This method is needed to enable loopd running as an external subserver in the same process as lnd but still validate its own macaroons.
func (*Daemon) WithdrawDeposits ¶
func (s *Daemon) WithdrawDeposits(ctx context.Context, req *looprpc.WithdrawDepositsRequest) ( *looprpc.WithdrawDepositsResponse, error)
WithdrawDeposits tries to obtain a partial signature from the server to spend the selected deposits to the client's wallet.
type ListenerCfg ¶
type ListenerCfg struct {
// contains filtered or unexported fields
}
ListenerCfg holds closures used to retrieve listeners for the gRPC services.
func NewListenerConfig ¶
func NewListenerConfig(config *Config, rpcCfg RPCConfig) *ListenerCfg
NewListenerConfig creates and returns a new listenerCfg from the passed config and RPCConfig.
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.