dcrlnd

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 140 Imported by: 1

README

dcrlnd

Build Status MIT License GoDoc

Lightning Network Daemon

The Decred Lightning Network Daemon (dcrlnd) - is a complete implementation of a Lightning Network node and currently deployed on testnet3 - the Decred Test Network.

dcrlnd currently requires a dcrd backing full node to perform the required chain services. The project's codebase uses the existing set of decred libraries, and also exports a large set of isolated re-usable Lightning Network related libraries within it. In the current state dcrlnd is capable of:

  • Creating channels.
  • Closing channels.
  • Completely managing all channel states (including the exceptional ones!).
  • Maintaining a fully authenticated+validated channel graph.
  • Performing path finding within the network, passively forwarding incoming payments.
  • Sending outgoing onion-encrypted payments through the network.
  • Updating advertised fee schedules.
  • Automatic channel management (autopilot).

LND Porting Status

dcrlnd is currently developed as a port of the original lnd lightning network daemon with the changes required to make it work on the Decred network and with Decred software.

Some of the most important (though by no means exhaustive) diffrences between lnd and dcrlnd include:

  • Import Paths
  • Full node integration API
  • Transaction serialization layout
  • Transaction witness format and signature process
  • Wallet integration API

Lightning Network Specification Compliance

dcrlnd aims to conform to the Lightning Network specification (BOLTs). BOLT stands for: Basis of Lightning Technology. The specifications are currently being drafted by several groups of implementers based around the world including the developers of dcrlnd. The set of specification documents as well as our implementation of the specification are still a work-in-progress. With that said, the current status of dcrlnd's BOLT compliance is:

  • BOLT 1: Base Protocol
  • BOLT 2: Peer Protocol for Channel Management
  • BOLT 3: Bitcoin Transaction and Script Formats
  • BOLT 4: Onion Routing Protocol
  • BOLT 5: Recommendations for On-chain Transaction Handling
  • BOLT 7: P2P Node and Channel Discovery
  • BOLT 8: Encrypted and Authenticated Transport
  • BOLT 9: Assigned Feature Flags
  • BOLT 10: DNS Bootstrap and Assisted Node Location
  • BOLT 11: Invoice Protocol for Lightning Payments

Developer Resources

The daemon has been designed to be as developer friendly as possible in order to facilitate application development on top of dcrlnd. Two primary RPC interfaces are exported: an HTTP REST API, and a gRPC service. The exported API's are not yet stable, so be warned: they may change drastically in the near future.

Most of the automatically generated documentation for the LND RPC APIs is applicable to dcrlnd and can be found at api.lightning.community. The developer resources including talks, articles, and example applications are also relevant to dcrlnd and can be found at: dev.lightning.community.

For questions and discussions, all Decred communities can be found at:

https://decred.org/community

Installation

Knowledgeable users may use the quickstart guide.

For more detailed instructions, please see the installation instructions.

The operation modes document lists how dcrlnd may connect to the Decred network to run its operations.

And a sample config file with annotated options is also available here.

Quick Simnet Network

A shell script that uses tmux to setup a 3-node simnet network (along with appropriate dcrd and dcrwallet nodes) is available in contrib/dcrlnd-tmux-3node.sh.

Note that this requires having dcrlnd and dcrlncli in your $PATH variable, as well as compatible versions of dcrd and dcrwallet.

Docker

To run lnd from Docker, please see the main Docker instructions

Safety

When operating a mainnet dcrlnd node, please refer to our operational safety guidelines. It is important to note that dcrlnd is still beta software and that ignoring these operational guidelines can lead to loss of funds.

Security

Please see the security policy.

Further reading

Documentation

Index

Constants

View Source
const UnassignedConnID uint64 = 0

UnassignedConnID is the default connection ID that a request can have before it actually is submitted to the connmgr. TODO(conner): move into connmgr package, or better, add connmgr method for generating atomic IDs

Variables

View Source
var (
	// DefaultLndDir is the default directory where lnd tries to find its
	// configuration file and store its data. This is a directory in the
	// user's application data, for example:
	// C:\Users\<username>\AppData\Local\Lnd on Windows ~/.lnd on Linux
	// ~/Library/Application Support/Lnd on MacOS
	DefaultLndDir = dcrutil.AppDataDir("dcrlnd", false)

	// DefaultConfigFile is the default full path of lnd's configuration
	// file.
	DefaultConfigFile = filepath.Join(DefaultLndDir, lncfg.DefaultConfigFilename)
)
View Source
var (
	// ErrPeerNotConnected signals that the server has no connection to the
	// given peer.
	ErrPeerNotConnected = errors.New("peer is not connected")

	// ErrServerNotActive indicates that the server has started but hasn't
	// fully finished the startup process.
	ErrServerNotActive = errors.New("server is still in the process of " +
		"starting")

	// ErrServerShuttingDown indicates that the server is in the process of
	// gracefully exiting.
	ErrServerShuttingDown = errors.New("server is shutting down")

	// MaxFundingAmount is a soft-limit of the maximum channel size
	// currently accepted within the Lightning Protocol. This is
	// defined in BOLT-0002, and serves as an initial precautionary limit
	// while implementations are battle tested in the real world.
	//
	// At the moment, this value depends on which chain is active. It is set
	// to the value under the Bitcoin chain as default.
	//
	// TODO(roasbeef): add command line param to modify
	MaxFundingAmount = funding.MaxFundingAmount
)
View Source
var (
	// MaxPaymentMAtoms is the maximum allowed payment currently permitted
	// as defined in BOLT-002. This value depends on which chain is active.
	// It is set to the value under the Decred chain as default.
	MaxPaymentMAtoms = maxDcrPaymentMAtoms
)

Functions

func AddSubLogger added in v0.3.0

func AddSubLogger(root *build.RotatingLogWriter, subsystem string,
	interceptor signal.Interceptor, useLoggers ...func(slog.Logger))

AddSubLogger is a helper method to conveniently create and register the logger of one or more sub systems.

func AdminAuthOptions added in v0.3.0

func AdminAuthOptions(cfg *Config, skipMacaroons bool) ([]grpc.DialOption,
	error)

AdminAuthOptions returns a list of DialOptions that can be used to authenticate with the RPC server with admin capabilities. skipMacaroons=true should be set if we don't want to include macaroons with the auth options. This is needed for instance for the WalletUnlocker service, which must be usable also before macaroons are created.

NOTE: This should only be called after the RPCListener has signaled it is ready.

func CleanAndExpandPath added in v0.3.0

func CleanAndExpandPath(path string) string

CleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it. This function is taken from https://github.com/decred/dcrd

func GetAllPermissions added in v0.6.0

func GetAllPermissions() []bakery.Op

GetAllPermissions returns all the permissions required to interact with lnd.

func Main added in v0.2.0

func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
	interceptor signal.Interceptor) error

Main is the true entry point for lnd. It accepts a fully populated and validated main configuration struct and an optional listener config struct. This function starts all main system components then blocks until a signal is received on the shutdownChan at which point everything is shut down again.

func MainRPCServerPermissions added in v0.3.0

func MainRPCServerPermissions() map[string][]bakery.Op

MainRPCServerPermissions returns a mapping of the main RPC server calls to the permissions they require.

func SetSubLogger added in v0.3.0

func SetSubLogger(root *build.RotatingLogWriter, subsystem string,
	logger slog.Logger, useLoggers ...func(slog.Logger))

SetSubLogger is a helper method to conveniently register the logger of a sub system.

func SetupLoggers added in v0.3.0

func SetupLoggers(root *build.RotatingLogWriter, interceptor signal.Interceptor)

SetupLoggers initializes all package-global logger variables.

Types

type ChainControlBuilder added in v0.6.0

type ChainControlBuilder interface {
	// BuildChainControl is responsible for creating a fully populated chain
	// control instance from a wallet.
	BuildChainControl(*chainreg.PartialChainControl,
		*chainreg.WalletConfig) (*chainreg.ChainControl, func(), error)
}

ChainControlBuilder is an interface that must be satisfied by a custom wallet implementation.

type Config added in v0.3.0

type Config struct {
	ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`

	LndDir       string `long:"lnddir" description:"The base directory that contains lnd's data, logs, configuration file, etc."`
	ConfigFile   string `short:"C" long:"configfile" description:"Path to configuration file"`
	DataDir      string `short:"b" long:"datadir" description:"The directory to store lnd's data within"`
	SyncFreelist bool   `` /* 233-byte string literal not displayed */

	TLSCertPath        string        `long:"tlscertpath" description:"Path to write the TLS certificate for lnd's RPC and REST services"`
	TLSKeyPath         string        `long:"tlskeypath" description:"Path to write the TLS private key for lnd'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          `` /* 173-byte string literal not displayed */
	TLSCertDuration    time.Duration `long:"tlscertduration" description:"The duration for which the auto-generated TLS certificate will be valid for"`

	NoMacaroons     bool          `long:"no-macaroons" description:"Disable macaroon authentication"`
	AdminMacPath    string        `long:"adminmacaroonpath" description:"Path to write the admin macaroon for lnd's RPC and REST services if it doesn't exist"`
	ReadMacPath     string        `` /* 130-byte string literal not displayed */
	InvoiceMacPath  string        `` /* 126-byte string literal not displayed */
	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"`
	AcceptorTimeout time.Duration `` /* 136-byte string literal not displayed */

	// IPC options
	PipeTx            *uint `long:"pipetx" description:"File descriptor or handle of write end pipe to enable child -> parent process communication"`
	PipeRx            *uint `long:"piperx" description:"File descriptor or handle of read end pipe to enable parent -> child process communication"`
	RPCListenerEvents bool  `long:"rpclistenerevents" description:"Notify JSON-RPC and gRPC listener addresses over the TX pipe"`

	LetsEncryptDir    string `long:"letsencryptdir" description:"The directory to store Let's Encrypt certificates within"`
	LetsEncryptListen string `` /* 471-byte string literal not displayed */
	LetsEncryptDomain string `` /* 184-byte string literal not displayed */

	// We'll parse these 'raw' string arguments into real net.Addrs in the
	// loadConfig function. We need to expose the 'raw' strings so the
	// command line library can access them.
	// Only the parsed net.Addrs should be used!
	RawRPCListeners   []string `long:"rpclisten" description:"Add an interface/port/socket to listen for RPC connections"`
	RawRESTListeners  []string `long:"restlisten" description:"Add an interface/port/socket to listen for REST connections"`
	RawListeners      []string `long:"listen" description:"Add an interface/port to listen for peer connections"`
	RawExternalIPs    []string `` /* 200-byte string literal not displayed */
	ExternalHosts     []string `long:"externalhosts" description:"A set of hosts that should be periodically resolved to announce IPs for"`
	RPCListeners      []net.Addr
	RESTListeners     []net.Addr
	RestCORS          []string `long:"restcors" description:"Add an ip:port/hostname to allow cross origin access from. To allow all origins, set as \"*\"."`
	Listeners         []net.Addr
	ExternalIPs       []net.Addr
	DisableListen     bool          `long:"nolisten" description:"Disable listening for incoming peer connections"`
	DisableRest       bool          `long:"norest" description:"Disable REST API"`
	DisableRestTLS    bool          `long:"no-rest-tls" description:"Disable TLS for REST connections"`
	WSPingInterval    time.Duration `` /* 156-byte string literal not displayed */
	WSPongWait        time.Duration `` /* 158-byte string literal not displayed */
	NAT               bool          `` /* 210-byte string literal not displayed */
	MinBackoff        time.Duration `long:"minbackoff" description:"Shortest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."`
	MaxBackoff        time.Duration `long:"maxbackoff" description:"Longest backoff when reconnecting to persistent peers. Valid time units are {s, m, h}."`
	ConnectionTimeout time.Duration `long:"connectiontimeout" description:"The timeout value for network connections. Valid time units are {ms, s, m, h}."`

	DebugLevel string `` /* 290-byte string literal not displayed */

	CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
	MemProfile string `long:"memprofile" description:"Write memory profile to the specified file"`

	Profile string `long:"profile" description:"Enable HTTP profiling on either a port or host:port"`

	UnsafeDisconnect   bool   `` /* 170-byte string literal not displayed */
	UnsafeReplay       bool   `` /* 157-byte string literal not displayed */
	MaxPendingChannels int    `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."`
	BackupFilePath     string `long:"backupfilepath" description:"The target location of the channel backup file"`

	FeeURL string `` /* 170-byte string literal not displayed */

	Decred    *lncfg.Chain
	DcrdMode  *lncfg.DcrdConfig      `group:"dcrd" namespace:"dcrd"`
	Dcrwallet *lncfg.DcrwalletConfig `group:"dcrwallet" namespace:"dcrwallet"`

	BlockCacheSize uint64 `long:"blockcachesize" description:"The maximum capacity of the block cache"`

	Autopilot *lncfg.AutoPilot `group:"Autopilot" namespace:"autopilot"`

	Automation *lncfg.Automation `group:"Automation" namespace:"automation"`

	Tor *lncfg.Tor `group:"Tor" namespace:"tor"`

	SubRPCServers *subRPCServerConfigs `group:"subrpc"`

	Hodl *hodl.Config `group:"hodl" namespace:"hodl"`

	NoNetBootstrap bool `long:"nobootstrap" description:"If true, then automatic network bootstrapping will not be attempted."`

	NoSeedBackup             bool   `` /* 205-byte string literal not displayed */
	WalletUnlockPasswordFile string `` /* 394-byte string literal not displayed */
	WalletUnlockAllowCreate  bool   `` /* 136-byte string literal not displayed */

	CoinSelectionStrategy string `long:"coin-selection-strategy" description:"The strategy to use for selecting coins for wallet transactions." choice:"random"`

	PaymentsExpirationGracePeriod time.Duration `` /* 190-byte string literal not displayed */
	TrickleDelay                  int           `long:"trickledelay" description:"Time in milliseconds between each release of announcements to the network"`
	ChanEnableTimeout             time.Duration `` /* 214-byte string literal not displayed */
	ChanDisableTimeout            time.Duration `` /* 338-byte string literal not displayed */
	ChanStatusSampleInterval      time.Duration `` /* 168-byte string literal not displayed */
	HeightHintCacheQueryDisable   bool          `` /* 329-byte string literal not displayed */
	Alias                         string        `long:"alias" description:"The node alias. Used as a moniker by peers and intelligence services"`
	Color                         string        `` /* 139-byte string literal not displayed */
	MinChanSize                   int64         `` /* 145-byte string literal not displayed */
	MaxChanSize                   int64         `` /* 143-byte string literal not displayed */
	CoopCloseTargetConfs          uint32        `` /* 243-byte string literal not displayed */

	ChannelCommitInterval  time.Duration `` /* 262-byte string literal not displayed */
	ChannelCommitBatchSize uint32        `` /* 143-byte string literal not displayed */

	DefaultRemoteMaxHtlcs uint16 `` /* 243-byte string literal not displayed */

	NumGraphSyncPeers      int           `` /* 184-byte string literal not displayed */
	HistoricalSyncInterval time.Duration `` /* 213-byte string literal not displayed */

	IgnoreHistoricalGossipFilters bool `` /* 240-byte string literal not displayed */

	RejectPush bool `` /* 170-byte string literal not displayed */

	RejectHTLC bool `` /* 203-byte string literal not displayed */

	StaggerInitialReconnect bool `` /* 246-byte string literal not displayed */

	MaxOutgoingCltvExpiry uint32 `long:"max-cltv-expiry" description:"The maximum number of blocks funds could be locked up for when forwarding payments."`

	MaxChannelFeeAllocation float64 `` /* 224-byte string literal not displayed */

	MaxCommitFeeRateAnchors uint64 `` /* 204-byte string literal not displayed */

	DryRunMigration bool `` /* 230-byte string literal not displayed */

	EnableUpfrontShutdown bool `` /* 397-byte string literal not displayed */

	AcceptKeySend bool `long:"accept-keysend" description:"If true, spontaneous payments through keysend will be accepted. [experimental]"`

	AcceptAMP bool `long:"accept-amp" description:"If true, spontaneous payments via AMP will be accepted."`

	KeysendHoldTime time.Duration `` /* 219-byte string literal not displayed */

	GcCanceledInvoicesOnStartup bool `long:"gc-canceled-invoices-on-startup" description:"If true, we'll attempt to garbage collect canceled invoices upon start."`

	GcCanceledInvoicesOnTheFly bool `long:"gc-canceled-invoices-on-the-fly" description:"If true, we'll delete newly canceled invoices on the fly."`

	DustThreshold uint64 `` /* 129-byte string literal not displayed */

	Invoices *lncfg.Invoices `group:"invoices" namespace:"invoices"`

	Routing *lncfg.Routing `group:"routing" namespace:"routing"`

	Gossip *lncfg.Gossip `group:"gossip" namespace:"gossip"`

	Workers *lncfg.Workers `group:"workers" namespace:"workers"`

	Caches *lncfg.Caches `group:"caches" namespace:"caches"`

	Prometheus lncfg.Prometheus `group:"prometheus" namespace:"prometheus"`

	WtClient *lncfg.WtClient `group:"wtclient" namespace:"wtclient"`

	Watchtower *lncfg.Watchtower `group:"watchtower" namespace:"watchtower"`

	ProtocolOptions *lncfg.ProtocolOptions `group:"protocol" namespace:"protocol"`

	AllowCircularRoute bool `` /* 128-byte string literal not displayed */

	HealthChecks *lncfg.HealthCheckConfig `group:"healthcheck" namespace:"healthcheck"`

	DB *lncfg.DB `group:"db" namespace:"db"`

	Cluster *lncfg.Cluster `group:"cluster" namespace:"cluster"`

	RPCMiddleware *lncfg.RPCMiddleware `group:"rpcmiddleware" namespace:"rpcmiddleware"`

	// LogWriter is the root logger that all of the daemon's subloggers are
	// hooked up to.
	LogWriter *build.RotatingLogWriter

	// ActiveNetParams contains parameters of the target chain.
	ActiveNetParams chainreg.DecredNetParams
	// contains filtered or unexported fields
}

Config defines the configuration options for lnd.

See LoadConfig for further details regarding the configuration loading+parsing process.

func DefaultConfig added in v0.3.0

func DefaultConfig() Config

DefaultConfig returns all default values for the Config struct.

func LoadConfig added in v0.3.0

func LoadConfig(interceptor signal.Interceptor) (*Config, error)

LoadConfig initializes and parses the config using a config file and command line options.

The configuration proceeds as follows:

  1. Start with a default config with sane settings
  2. Pre-parse the command line to check for an alternative config file
  3. Load configuration file overwriting defaults with any specified options
  4. Parse CLI options and overwrite/add any specified options

func ValidateConfig added in v0.3.0

func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
	flagParser *flags.Parser) (*Config, error)

ValidateConfig check the given configuration to be sane. This makes sure no illegal values or combination of values are set. All file system paths are normalized. The cleaned up config is returned on success.

func (*Config) ImplementationConfig added in v0.6.0

func (c *Config) ImplementationConfig(
	interceptor signal.Interceptor) *ImplementationCfg

ImplementationConfig returns the configuration of what actual implementations should be used when creating the main lnd instance.

type CustomMessage added in v0.6.0

type CustomMessage struct {
	// Peer is the peer pubkey
	Peer [33]byte

	// Msg is the custom wire message.
	Msg *lnwire.Custom
}

CustomMessage is a custom message that is received from a peer.

type DatabaseBuilder added in v0.6.0

type DatabaseBuilder interface {
	// BuildDatabase extracts the current databases that we'll use for
	// normal operation in the daemon. A function closure that closes all
	// opened databases is also returned.
	BuildDatabase(ctx context.Context) (*DatabaseInstances, func(), error)
}

DatabaseBuilder is an interface that must be satisfied by the implementation that provides lnd's main database backend instances.

type DatabaseInstances added in v0.6.0

type DatabaseInstances struct {
	// GraphDB is the database that stores the channel graph used for path
	// finding.
	//
	// NOTE/TODO: This currently _needs_ to be the same instance as the
	// ChanStateDB below until the separation of the two databases is fully
	// complete!
	GraphDB *channeldb.DB

	// ChanStateDB is the database that stores all of our node's channel
	// state.
	//
	// NOTE/TODO: This currently _needs_ to be the same instance as the
	// GraphDB above until the separation of the two databases is fully
	// complete!
	ChanStateDB *channeldb.DB

	// HeightHintDB is the database that stores height hints for spends.
	HeightHintDB kvdb.Backend

	// MacaroonDB is the database that stores macaroon root keys.
	MacaroonDB kvdb.Backend

	// DecayedLogDB is the database that stores p2p related encryption
	// information.
	DecayedLogDB kvdb.Backend

	// TowerClientDB is the database that stores the watchtower client's
	// configuration.
	TowerClientDB wtclient.DB

	// TowerServerDB is the database that stores the watchtower server's
	// configuration.
	TowerServerDB watchtower.DB

	// WalletDB is the configuration for loading the wallet database using
	// the btcwallet's loader.
	WalletDB walletloader.LoaderOption
}

DatabaseInstances is a struct that holds all instances to the actual databases that are used in lnd.

type DefaultDatabaseBuilder added in v0.6.0

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

DefaultDatabaseBuilder is a type that builds the default database backends for lnd, using the given configuration to decide what actual implementation to use.

func NewDefaultDatabaseBuilder added in v0.6.0

func NewDefaultDatabaseBuilder(cfg *Config,
	logger slog.Logger) *DefaultDatabaseBuilder

NewDefaultDatabaseBuilder returns a new instance of the default database builder.

func (*DefaultDatabaseBuilder) BuildDatabase added in v0.6.0

func (d *DefaultDatabaseBuilder) BuildDatabase(
	ctx context.Context) (*DatabaseInstances, func(), error)

BuildDatabase extracts the current databases that we'll use for normal operation in the daemon. A function closure that closes all opened databases is also returned.

type DefaultWalletImpl added in v0.6.0

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

DefaultWalletImpl is the default implementation of our normal, btcwallet backed configuration.

func NewDefaultWalletImpl added in v0.6.0

func NewDefaultWalletImpl(cfg *Config, logger slog.Logger,
	interceptor signal.Interceptor) *DefaultWalletImpl

NewDefaultWalletImpl creates a new default wallet implementation.

func (*DefaultWalletImpl) BuildChainControl added in v0.6.0

func (d *DefaultWalletImpl) BuildChainControl(
	partialChainControl *chainreg.PartialChainControl,
	walletConfig *chainreg.WalletConfig) (*chainreg.ChainControl, func(), error)

BuildChainControl is responsible for creating a fully populated chain control instance from a wallet.

NOTE: This is part of the ChainControlBuilder interface.

func (*DefaultWalletImpl) BuildWalletConfig added in v0.6.0

func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
	dbs *DatabaseInstances, interceptorChain *rpcperms.InterceptorChain,
	grpcListeners []*ListenerWithSignal) (*chainreg.PartialChainControl,
	*chainreg.WalletConfig, func(), error)

BuildWalletConfig is responsible for creating or unlocking and then fully initializing a wallet.

NOTE: This is part of the WalletConfigBuilder interface.

func (*DefaultWalletImpl) Permissions added in v0.6.0

func (d *DefaultWalletImpl) Permissions() map[string][]bakery.Op

Permissions returns the permissions that the external validator is validating. It is a map between the full HTTP URI of each RPC and its required macaroon permissions. If multiple action/entity tuples are specified per URI, they are all required. See rpcserver.go for a list of valid action and entity values.

NOTE: This is part of the ExternalValidator interface.

func (*DefaultWalletImpl) RegisterGrpcSubserver added in v0.6.0

func (d *DefaultWalletImpl) RegisterGrpcSubserver(s *grpc.Server) error

RegisterGrpcSubserver is called for each net.Listener on which lnd creates a grpc.Server instance. External subservers implementing this method can then register their own gRPC server structs to the main server instance.

NOTE: This is part of the GrpcRegistrar interface.

func (*DefaultWalletImpl) RegisterRestSubserver added in v0.6.0

func (d *DefaultWalletImpl) RegisterRestSubserver(ctx context.Context,
	mux *proxy.ServeMux, restProxyDest string,
	restDialOpts []grpc.DialOption) error

RegisterRestSubserver is called after lnd creates the main proxy.ServeMux instance. External subservers implementing this method can then register their own REST proxy stubs to the main server instance.

NOTE: This is part of the GrpcRegistrar interface.

func (*DefaultWalletImpl) ValidateMacaroon added in v0.6.0

func (d *DefaultWalletImpl) 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.

NOTE: This is part of the ExternalValidator interface.

type ExternalValidator added in v0.6.0

type ExternalValidator interface {
	macaroons.MacaroonValidator

	// Permissions returns the permissions that the external validator is
	// validating. It is a map between the full HTTP URI of each RPC and its
	// required macaroon permissions. If multiple action/entity tuples are
	// specified per URI, they are all required. See rpcserver.go for a list
	// of valid action and entity values.
	Permissions() map[string][]bakery.Op
}

ExternalValidator is an interface that must be satisfied by an external macaroon validator.

type GrpcRegistrar added in v0.3.0

type GrpcRegistrar interface {
	// RegisterGrpcSubserver is called for each net.Listener on which lnd
	// creates a grpc.Server instance. External subservers implementing this
	// method can then register their own gRPC server structs to the main
	// server instance.
	RegisterGrpcSubserver(*grpc.Server) error
}

GrpcRegistrar is an interface that must be satisfied by an external subserver that wants to be able to register its own gRPC server onto lnd's main grpc.Server instance.

type ImplementationCfg added in v0.6.0

type ImplementationCfg struct {
	// GrpcRegistrar is a type that can register additional gRPC subservers
	// before the main gRPC server is started.
	GrpcRegistrar

	// RestRegistrar is a type that can register additional REST subservers
	// before the main REST proxy is started.
	RestRegistrar

	// ExternalValidator is a type that can provide external macaroon
	// validation.
	ExternalValidator

	// DatabaseBuilder is a type that can provide lnd's main database
	// backend instances.
	DatabaseBuilder

	// WalletConfigBuilder is a type that can provide a wallet configuration
	// with a fully loaded and unlocked wallet.
	WalletConfigBuilder

	// ChainControlBuilder is a type that can provide a custom wallet
	// implementation.
	ChainControlBuilder
}

ImplementationCfg is a struct that holds all configuration items for components that can be implemented outside lnd itself.

type ListenerCfg added in v0.2.0

type ListenerCfg struct {
	// RPCListeners can be set to the listeners to use for the RPC server.
	// If empty a regular network listener will be created.
	RPCListeners []*ListenerWithSignal
}

ListenerCfg is a wrapper around custom listeners that can be passed to lnd when calling its main method.

type ListenerWithSignal added in v0.3.0

type ListenerWithSignal struct {
	net.Listener

	// Ready will be closed by the server listening on Listener.
	Ready chan struct{}

	// MacChan is an optional way to pass the admin macaroon to the program
	// that started lnd. The channel should be buffered to avoid lnd being
	// blocked on sending to the channel.
	MacChan chan []byte
}

ListenerWithSignal is a net.Listener that has an additional Ready channel that will be closed when a server starts listening.

type RemoteWalletBuilder added in v0.6.0

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

func (*RemoteWalletBuilder) BuildChainControl added in v0.6.0

func (rb *RemoteWalletBuilder) BuildChainControl(
	partialChainControl *chainreg.PartialChainControl,
	walletConfig *chainreg.WalletConfig) (*chainreg.ChainControl, func(), error)

type RestRegistrar added in v0.3.0

type RestRegistrar interface {
	// RegisterRestSubserver is called after lnd creates the main
	// proxy.ServeMux instance. External subservers implementing this method
	// can then register their own REST proxy stubs to the main server
	// instance.
	RegisterRestSubserver(context.Context, *proxy.ServeMux, string,
		[]grpc.DialOption) error
}

RestRegistrar is an interface that must be satisfied by an external subserver that wants to be able to register its own REST mux onto lnd's main proxy.ServeMux instance.

type WalletConfigBuilder added in v0.6.0

type WalletConfigBuilder interface {
	// BuildWalletConfig is responsible for creating or unlocking and then
	// fully initializing a wallet.
	BuildWalletConfig(context.Context, *DatabaseInstances,
		*rpcperms.InterceptorChain,
		[]*ListenerWithSignal) (*chainreg.PartialChainControl,
		*chainreg.WalletConfig, func(), error)
}

WalletConfigBuilder is an interface that must be satisfied by a custom wallet implementation.

Directories

Path Synopsis
Package chanfitness monitors the behaviour of channels to provide insight into the health and performance of a channel.
Package chanfitness monitors the behaviour of channels to provide insight into the health and performance of a channel.
cmd
Package healthcheck contains a monitor which takes a set of liveliness checks which it periodically checks.
Package healthcheck contains a monitor which takes a set of liveliness checks which it periodically checks.
hop
internal
zero
Package zero contains functions to clear data from byte slices and multi-precision integers.
Package zero contains functions to clear data from byte slices and multi-precision integers.
Package labels contains labels used to label transactions broadcast by lnd.
Package labels contains labels used to label transactions broadcast by lnd.
Package lnrpc is a reverse proxy.
Package lnrpc is a reverse proxy.
autopilotrpc
Package autopilotrpc is a reverse proxy.
Package autopilotrpc is a reverse proxy.
chainrpc
Package chainrpc is a reverse proxy.
Package chainrpc is a reverse proxy.
initchainsyncrpc
Package initchainsyncrpc is a reverse proxy.
Package initchainsyncrpc is a reverse proxy.
invoicesrpc
Package invoicesrpc is a reverse proxy.
Package invoicesrpc is a reverse proxy.
routerrpc
Package routerrpc is a reverse proxy.
Package routerrpc is a reverse proxy.
signrpc
Package signrpc is a reverse proxy.
Package signrpc is a reverse proxy.
verrpc
Package verrpc is a reverse proxy.
Package verrpc is a reverse proxy.
walletrpc
Package walletrpc is a reverse proxy.
Package walletrpc is a reverse proxy.
watchtowerrpc
Package watchtowerrpc is a reverse proxy.
Package watchtowerrpc is a reverse proxy.
wtclientrpc
Package wtclientrpc is a reverse proxy.
Package wtclientrpc is a reverse proxy.
Package lntest provides testing utilities for the dcrlnd repository.
Package lntest provides testing utilities for the dcrlnd repository.
dcrwallet/loader
Package loader provides a concurrent safe implementation of a wallet loader.
Package loader provides a concurrent safe implementation of a wallet loader.
lru

Jump to

Keyboard shortcuts

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