{"modulePath":"github.com/lightninglabs/loop","version":"v0.36.0-beta","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package loopd\n\n## Constants\n\n```go\nconst Subsystem = \"LOOPD\"\n```\n\n## Variables\n\n```go\nvar (\n\t// LoopDirBase is the default main directory where loop stores its data.\n\tLoopDirBase = btcutil.AppDataDir(\"loop\", false)\n\n\t// DefaultNetwork is the default bitcoin network loop runs on.\n\tDefaultNetwork = \"mainnet\"\n\n\t// DefaultTLSCertFilename is the default file name for the autogenerated\n\t// TLS certificate.\n\tDefaultTLSCertFilename = \"tls.cert\"\n\n\t// DefaultTLSKeyFilename is the default file name for the autogenerated\n\t// TLS key.\n\tDefaultTLSKeyFilename = \"tls.key\"\n\n\t// DatabaseBackendSqlite is the name of the SQLite database backend.\n\tDatabaseBackendSqlite = \"sqlite\"\n\n\t// DatabaseBackendPostgres is the name of the Postgres database backend.\n\tDatabaseBackendPostgres = \"postgres\"\n\n\t// DefaultLndMacaroonPath is the default mainnet admin macaroon path of\n\t// LND.\n\tDefaultLndMacaroonPath = filepath.Join(\n\t\tbtcutil.AppDataDir(\"lnd\", false),\n\t\t\"data\", \"chain\", \"bitcoin\", DefaultNetwork,\n\t\tdefaultLndMacaroon,\n\t)\n\n\t// DefaultLndRPCTimeout is the default timeout to use when communicating\n\t// with lnd.\n\tDefaultLndRPCTimeout = time.Minute\n\n\t// DefaultTLSCertPath is the default full path of the autogenerated TLS\n\t// certificate.\n\tDefaultTLSCertPath = filepath.Join(\n\t\tLoopDirBase, DefaultNetwork, DefaultTLSCertFilename,\n\t)\n\n\t// DefaultTLSKeyPath is the default full path of the autogenerated TLS\n\t// key.\n\tDefaultTLSKeyPath = filepath.Join(\n\t\tLoopDirBase, DefaultNetwork, DefaultTLSKeyFilename,\n\t)\n\n\t// DefaultMacaroonFilename is the default file name for the\n\t// autogenerated loop macaroon.\n\tDefaultMacaroonFilename = \"loop.macaroon\"\n\n\t// DefaultMacaroonPath is the default full path of the base loop\n\t// macaroon.\n\tDefaultMacaroonPath = filepath.Join(\n\t\tLoopDirBase, DefaultNetwork, DefaultMacaroonFilename,\n\t)\n\n\t// DefaultAutogenValidity is the default validity of a self-signed\n\t// certificate in number of days.\n\tDefaultAutogenValidity = 365 * 24 * time.Hour\n)\n```\n\n```go\nvar (\n\t// LoopMinRequiredLndVersion is the minimum required version of lnd that\n\t// is compatible with the current version of the loop client. Also all\n\t// listed build tags/subservers need to be enabled.\n\t//\n\t// IMPORTANT: bump this whenever the client starts using an lnd RPC\n\t// method or message field that does not exist in older lnd, or starts\n\t// relying on lnd behavior that older lnd lacks, to the lnd release that\n\t// introduced it (see the maintenance note in AGENTS.md). The current\n\t// floor of v0.19.0-beta is set by the highest such dependency the\n\t// client has today:\n\t//   - routerrpc.SendPaymentV2 with timeout_seconds unset, which\n\t//     lndclient's PayInvoice sends when aperture's interceptor pays\n\t//     for the L402 token (swap_server_client.go): lnd v0.19.0-beta\n\t//     defaults the timeout to 60 seconds, older lnd rejects the\n\t//     payment with \"timeout_seconds must be specified\".\n\t//   - bLIP 39 invoice payments, including multipart payments to blinded\n\t//     paths (loopout.go), are supported by lnd v0.19.0-beta.\n\t//   - routerrpc.SendPaymentRequest.first_hop_custom_records and\n\t//     lnrpc.Route.custom_channel_data, used by asset loop outs\n\t//     (loopout.go): both added in lnd v0.18.4-beta.\n\t//   - walletrpc.EstimateFeeResponse.min_relay_fee_sat_per_kw, read by\n\t//     the sweep batcher fee floor via lndclient WalletKit.MinRelayFee\n\t//     (sweepbatcher/, loopd/sweep_htlc.go): added in lnd v0.18.3-beta.\n\t//     On older lnd this field silently decodes to 0, disabling the\n\t//     sweeper's min-relay fee floor.\n\tLoopMinRequiredLndVersion = \u0026verrpc.Version{\n\t\tAppMajor: 0,\n\t\tAppMinor: 19,\n\t\tAppPatch: 0,\n\t\tBuildTags: []string{\n\t\t\t\"signrpc\", \"walletrpc\", \"chainrpc\", \"invoicesrpc\",\n\t\t},\n\t}\n)\n```\n\n## Functions\n\n```go\nfunc Run(rpcCfg RPCConfig) error\n```\nRun starts the loop daemon and blocks until it's shut down again.\n\n```go\nfunc SetupLoggers(root *build.SubLoggerManager, intercept signal.Interceptor)\n```\nSetupLoggers initializes all package-global logger variables.\n\n```go\nfunc ToClientReservations(\n\tres []*reservation.Reservation) []*looprpc.ClientReservation\n```\nToClientReservations converts a slice of server reservations to a slice of client reservations.\n\n```go\nfunc Validate(cfg *Config) error\n```\nValidate cleans up paths in the config provided and validates it.\n\n## Types\n\n```go\ntype Config struct {\n\tShowVersion bool   `long:\"version\" description:\"Display version information and exit\"`\n\tNetwork     string `long:\"network\" description:\"network to run on\" choice:\"regtest\" choice:\"testnet\" choice:\"mainnet\" choice:\"simnet\" choice:\"signet\"`\n\tRPCListen   string `long:\"rpclisten\" description:\"Address to listen on for gRPC clients\"`\n\tRESTListen  string `long:\"restlisten\" description:\"Address to listen on for REST clients\"`\n\tCORSOrigin  string `long:\"corsorigin\" description:\"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty.\"`\n\n\tLoopDir    string `long:\"loopdir\" description:\"The directory for all of loop's data. If set, this option overwrites --datadir, --logdir, --tlscertpath, --tlskeypath and --macaroonpath.\"`\n\tConfigFile string `long:\"configfile\" description:\"Path to configuration file.\"`\n\tDataDir    string `long:\"datadir\" description:\"Directory for loopdb.\"`\n\n\tDatabaseBackend string                 `long:\"databasebackend\" description:\"The database backend to use for storing all asset related data.\" choice:\"sqlite\" choice:\"postgres\"`\n\tSqlite          *loopdb.SqliteConfig   `group:\"sqlite\" namespace:\"sqlite\"`\n\tPostgres        *loopdb.PostgresConfig `group:\"postgres\" namespace:\"postgres\"`\n\n\tTLSCertPath        string        `long:\"tlscertpath\" description:\"Path to write the TLS certificate for loop's RPC and REST services.\"`\n\tTLSKeyPath         string        `long:\"tlskeypath\" description:\"Path to write the TLS private key for loop's RPC and REST services.\"`\n\tTLSExtraIPs        []string      `long:\"tlsextraip\" description:\"Adds an extra IP to the generated certificate.\"`\n\tTLSExtraDomains    []string      `long:\"tlsextradomain\" description:\"Adds an extra domain to the generated certificate.\"`\n\tTLSAutoRefresh     bool          `long:\"tlsautorefresh\" description:\"Re-generate TLS certificate and key if the IPs or domains are changed.\"`\n\tTLSDisableAutofill bool          `long:\"tlsdisableautofill\" description:\"Do not include the interface IPs or the system hostname in TLS certificate, use first --tlsextradomain as Common Name instead, if set.\"`\n\tTLSValidity        time.Duration `long:\"tlsvalidity\" description:\"Loop's TLS certificate validity period in days. Defaults to 8760h (1 year)\"`\n\n\tMacaroonPath string `long:\"macaroonpath\" description:\"Path to write the macaroon for loop's RPC and REST services if it doesn't exist.\"`\n\n\tLogDir         string `long:\"logdir\" description:\"Directory to log output.\"`\n\tMaxLogFiles    int    `long:\"maxlogfiles\" hidden:\"true\" description:\"DEPRECATED! Use logging.file.max-files instead. Maximum logfiles to keep (0 for no rotation)\"`\n\tMaxLogFileSize int    `long:\"maxlogfilesize\" hidden:\"true\" description:\"DEPRECATED! Use logging.file.max-file-size instead. Maximum logfile size in MB\"`\n\n\tLogging *build.LogConfig `group:\"logging\" namespace:\"logging\"`\n\n\tDebugLevel  string `long:\"debuglevel\" description:\"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify \u003csubsystem\u003e=\u003clevel\u003e,\u003csubsystem2\u003e=\u003clevel\u003e,... to set the log level for individual subsystems -- Use show to list available subsystems\"`\n\tMaxLSATCost uint32 `long:\"maxlsatcost\" hidden:\"true\"`\n\tMaxLSATFee  uint32 `long:\"maxlsatfee\" hidden:\"true\"`\n\tMaxL402Cost uint32 `long:\"maxl402cost\" description:\"Maximum cost in satoshis that loopd is going to pay for an L402 token automatically. Does not include routing fees.\"`\n\tMaxL402Fee  uint32 `long:\"maxl402fee\" description:\"Maximum routing fee in satoshis that we are willing to pay while paying for an L402 token.\"`\n\n\tLoopOutMaxParts uint32 `long:\"loopoutmaxparts\" description:\"The maximum number of payment parts that may be used for a loop out swap.\"`\n\n\tSkippedTxns []string `long:\"skippedtxns\" description:\"The list of existing HTLC txids to skip when starting Loop. This should only be used if affected by the historical bug.\" hidden:\"true\"`\n\n\tTotalPaymentTimeout time.Duration `long:\"totalpaymenttimeout\" description:\"The timeout to use for off-chain payments.\"`\n\tMaxPaymentRetries   int           `long:\"maxpaymentretries\" description:\"The maximum number of times an off-chain payment may be retried.\"`\n\n\tMaxStaticAddrHtlcFeePercentage       float64 `long:\"maxstaticaddrhtlcfeepercentage\" description:\"The maximum fee percentage that the server can charge for the htlc tx.\"`\n\tMaxStaticAddrHtlcBackupFeePercentage float64 `long:\"maxstaticaddrhtlcbackupfeepercentage\" description:\"The maximum fee percentage that the server can charge for the htlc backup tx. The backup transaction is only used in rare cases when the regular htlc tx is not confirmed on time. These backup transactions refer to high fee or extremely high fee transactions in the API.\"`\n\n\tEnableExperimental bool `long:\"experimental\" description:\"Enable experimental features: reservations, static autoloop\"`\n\n\tMigrationRPCBatchSize int `long:\"migrationrpcbatchsize\" description:\"The RPC batch size to use during migrations.\"`\n\n\tLnd *lndConfig `group:\"lnd\" namespace:\"lnd\"`\n\n\tServer *loopServerConfig `group:\"server\" namespace:\"server\"`\n\n\tTapd *assets.TapdConfig `group:\"tapd\" namespace:\"tapd\"`\n\n\tView viewParameters `command:\"view\" alias:\"v\" description:\"View all swaps in the database. This command can only be executed when loopd is not running.\"`\n}\n```\n\n```go\nfunc DefaultConfig() Config\n```\nDefaultConfig returns all default values for the Config struct.\n\n```go\ntype Daemon struct {\n\n\t// ErrChan is an error channel that users of the Daemon struct must use\n\t// to detect runtime errors and also whether a shutdown is fully\n\t// completed.\n\tErrChan chan error\n\t// contains filtered or unexported fields\n}\n```\nDaemon is the struct that holds one instance of the loop client daemon.\n\n```go\nfunc New(config *Config, lisCfg *ListenerCfg) *Daemon\n```\nNew creates a new instance of the loop client daemon.\n\n```go\nfunc (s *Daemon) AbandonSwap(ctx context.Context,\n\treq *looprpc.AbandonSwapRequest) (*looprpc.AbandonSwapResponse,\n\terror)\n```\nAbandonSwap requests the server to abandon a swap with the given hash.\n\n```go\nfunc (s *Daemon) FetchL402Token(ctx context.Context,\n\t_ *looprpc.FetchL402TokenRequest) (*looprpc.FetchL402TokenResponse,\n\terror)\n```\nFetchL402Token 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.\n\n```go\nfunc (s *Daemon) GetInfo(ctx context.Context,\n\t_ *looprpc.GetInfoRequest) (*looprpc.GetInfoResponse, error)\n```\nGetInfo returns basic information about the loop daemon and details to swaps from the swap store.\n\n```go\nfunc (s *Daemon) GetL402Tokens(ctx context.Context,\n\t_ *looprpc.TokensRequest) (*looprpc.TokensResponse, error)\n```\nGetL402Tokens returns all tokens that are contained in the L402 token store.\n\n```go\nfunc (s *Daemon) GetLiquidityParams(_ context.Context,\n\t_ *looprpc.GetLiquidityParamsRequest) (*looprpc.LiquidityParameters,\n\terror)\n```\nGetLiquidityParams gets our current liquidity manager's parameters.\n\n```go\nfunc (s *Daemon) GetLoopInQuote(ctx context.Context,\n\treq *looprpc.QuoteRequest) (*looprpc.InQuoteResponse, error)\n```\nGetLoopInQuote returns a quote for a swap with the provided parameters.\n\n```go\nfunc (s *Daemon) GetLoopInTerms(ctx context.Context,\n\t_ *looprpc.TermsRequest) (*looprpc.InTermsResponse, error)\n```\nGetLoopInTerms returns the terms that the server enforces for swaps.\n\n```go\nfunc (s *Daemon) GetLsatTokens(ctx context.Context,\n\treq *looprpc.TokensRequest) (*looprpc.TokensResponse, error)\n```\nGetLsatTokens returns all tokens that are contained in the L402 token store.\n\nDeprecated: 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.\n\n```go\nfunc (s *Daemon) GetStaticAddressSummary(ctx context.Context,\n\t_ *looprpc.StaticAddressSummaryRequest) (\n\t*looprpc.StaticAddressSummaryResponse, error)\n```\nGetStaticAddressSummary returns a summary of 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.\n\n```go\nfunc (s *Daemon) InstantOut(ctx context.Context,\n\treq *looprpc.InstantOutRequest) (*looprpc.InstantOutResponse,\n\terror)\n```\nInstantOut initiates an instant out swap.\n\n```go\nfunc (s *Daemon) InstantOutQuote(ctx context.Context,\n\treq *looprpc.InstantOutQuoteRequest) (\n\t*looprpc.InstantOutQuoteResponse, error)\n```\nInstantOutQuote returns a quote for an instant out swap with the provided parameters.\n\n```go\nfunc (s *Daemon) ListInstantOuts(ctx context.Context,\n\t_ *looprpc.ListInstantOutsRequest) (\n\t*looprpc.ListInstantOutsResponse, error)\n```\nListInstantOuts returns a list of all currently known instant out swaps and their current status.\n\n```go\nfunc (s *Daemon) ListReservations(ctx context.Context,\n\t_ *looprpc.ListReservationsRequest) (\n\t*looprpc.ListReservationsResponse, error)\n```\nListReservations lists all existing reservations the client has ever made.\n\n```go\nfunc (s *Daemon) ListStaticAddressDeposits(ctx context.Context,\n\treq *looprpc.ListStaticAddressDepositsRequest) (\n\t*looprpc.ListStaticAddressDepositsResponse, error)\n```\nListStaticAddressDeposits returns a list of all sufficiently confirmed deposits behind the static address and displays properties like value, state or blocks til expiry.\n\n```go\nfunc (s *Daemon) ListStaticAddressSwaps(ctx context.Context,\n\t_ *looprpc.ListStaticAddressSwapsRequest) (\n\t*looprpc.ListStaticAddressSwapsResponse, error)\n```\nListStaticAddressSwaps returns a list of all swaps that are currently pending or previously succeeded.\n\n```go\nfunc (s *Daemon) ListStaticAddressWithdrawals(ctx context.Context,\n\t_ *looprpc.ListStaticAddressWithdrawalRequest) (\n\t*looprpc.ListStaticAddressWithdrawalResponse, error)\n```\nListStaticAddressWithdrawals returns a list of all finalized withdrawal transactions.\n\n```go\nfunc (s *Daemon) ListSwaps(ctx context.Context,\n\treq *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error)\n```\nListSwaps returns a list of all currently known swaps and their current status.\n\n```go\nfunc (s *Daemon) ListUnspentDeposits(ctx context.Context,\n\treq *looprpc.ListUnspentDepositsRequest) (\n\t*looprpc.ListUnspentDepositsResponse, error)\n```\nListUnspentDeposits returns a list of utxos behind the static address.\n\n```go\nfunc (s *Daemon) LoopIn(ctx context.Context,\n\tin *looprpc.LoopInRequest) (*looprpc.SwapResponse, error)\n```\n\n```go\nfunc (s *Daemon) LoopOut(ctx context.Context,\n\tin *looprpc.LoopOutRequest) (\n\t*looprpc.SwapResponse, error)\n```\nLoopOut 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().\n\n```go\nfunc (s *Daemon) LoopOutQuote(ctx context.Context,\n\treq *looprpc.QuoteRequest) (*looprpc.OutQuoteResponse, error)\n```\nLoopOutQuote returns a quote for a loop out swap with the provided parameters.\n\n```go\nfunc (s *Daemon) LoopOutTerms(ctx context.Context,\n\t_ *looprpc.TermsRequest) (*looprpc.OutTermsResponse, error)\n```\nLoopOutTerms returns the terms that the server enforces for loop out swaps.\n\n```go\nfunc (s *Daemon) Monitor(in *looprpc.MonitorRequest,\n\tserver looprpc.SwapClient_MonitorServer) error\n```\nMonitor will return a stream of swap updates for currently active swaps.\n\n```go\nfunc (s *Daemon) NewStaticAddress(ctx context.Context,\n\t_ *looprpc.NewStaticAddressRequest) (*looprpc.NewStaticAddressResponse,\n\terror)\n```\nNewStaticAddress creates a fresh static receive address without funding it.\n\n```go\nfunc (s *Daemon) Probe(ctx context.Context,\n\treq *looprpc.ProbeRequest) (*looprpc.ProbeResponse, error)\n```\nProbe requests the server to probe the client's node to test inbound liquidity.\n\n```go\nfunc (s *Daemon) SetLiquidityParams(ctx context.Context,\n\tin *looprpc.SetLiquidityParamsRequest) (*looprpc.SetLiquidityParamsResponse,\n\terror)\n```\nSetLiquidityParams attempts to set our current liquidity manager's parameters.\n\n```go\nfunc (d *Daemon) Start() error\n```\nStart starts loopd in daemon mode. It will listen for grpc connections, execute commands and pass back swap status information.\n\n```go\nfunc (d *Daemon) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices,\n\twithMacaroonService bool) error\n```\nStartAsSubserver 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.\n\n```go\nfunc (s *Daemon) StaticAddressLoopIn(ctx context.Context,\n\tin *looprpc.StaticAddressLoopInRequest) (\n\t*looprpc.StaticAddressLoopInResponse, error)\n```\nStaticAddressLoopIn initiates a loop-in request using static address deposits.\n\n```go\nfunc (s *Daemon) StaticOpenChannel(ctx context.Context,\n\treq *looprpc.StaticOpenChannelRequest) (*looprpc.StaticOpenChannelResponse,\n\terror)\n```\nStaticOpenChannel initiates an open channel request using static address deposits.\n\n```go\nfunc (d *Daemon) Stop()\n```\nStop 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.\n\n```go\nfunc (s *Daemon) StopDaemon(ctx context.Context,\n\t_ *looprpc.StopDaemonRequest) (*looprpc.StopDaemonResponse, error)\n```\nStopDaemon triggers a graceful shutdown of the daemon process.\n\n```go\nfunc (s *Daemon) SuggestSwaps(ctx context.Context,\n\t_ *looprpc.SuggestSwapsRequest) (*looprpc.SuggestSwapsResponse, error)\n```\nSuggestSwaps provides a list of suggested swaps based on lnd's current channel balances and rules set by the liquidity manager.\n\n```go\nfunc (s *Daemon) SwapInfo(ctx context.Context,\n\treq *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error)\n```\nSwapInfo returns all known details about a single swap.\n\n```go\nfunc (s *Daemon) SweepHtlc(ctx context.Context,\n\treq *looprpc.SweepHtlcRequest) (*looprpc.SweepHtlcResponse, error)\n```\nSweepHtlc spends a Loop HTLC output using the success path and a known preimage.\n\n```go\nfunc (d *Daemon) ValidateMacaroon(ctx context.Context,\n\trequiredPermissions []bakery.Op, fullMethod string) error\n```\nValidateMacaroon 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.\n\n```go\nfunc (s *Daemon) WithdrawDeposits(ctx context.Context,\n\treq *looprpc.WithdrawDepositsRequest) (\n\t*looprpc.WithdrawDepositsResponse, error)\n```\nWithdrawDeposits tries to obtain a partial signature from the server to spend the selected deposits to the client's wallet.\n\n```go\ntype ListenerCfg struct {\n\t// contains filtered or unexported fields\n}\n```\nListenerCfg holds closures used to retrieve listeners for the gRPC services.\n\n```go\nfunc NewListenerConfig(config *Config, rpcCfg RPCConfig) *ListenerCfg\n```\nNewListenerConfig creates and returns a new listenerCfg from the passed config and RPCConfig.\n\n```go\ntype RPCConfig struct {\n\t// RPCListener is an optional listener that if set will override the\n\t// daemon's gRPC settings, and make the gRPC server listen on this\n\t// listener.\n\t// Note that setting this will also disable REST.\n\tRPCListener net.Listener\n\n\t// LndConn is an optional connection to an lnd instance. If set it will\n\t// override the TCP connection created from daemon's config.\n\tLndConn net.Conn\n}\n```\nRPCConfig holds optional options that can be used to make the loop daemon communicate on custom connections.\n\n","path":"github.com/lightninglabs/loop/loopd","name":"loopd","synopsis":"","isRedistributable":true}
