boltnd

package module
v0.0.0-...-a596a23 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 19 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	// DefaultLNDRetries is the default number of times we retry connecting
	// to lnd before erroring out.
	DefaultLNDRetries = 4

	// DefaultLNDWait is the default amount of time we backoff between
	// lnd connection attempts.
	DefaultLNDWait = time.Second * 10
)
View Source
const Subsystem = "B12-OFRS"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var MinimumLNDVersion = &verrpc.Version{
	AppMajor: 0,
	AppMinor: 15,
	AppPatch: 0,
	BuildTags: []string{
		"signrpc", "walletrpc", "chainrpc", "invoicesrpc",
	},
}

MinimumLNDVersion is the minimum lnd version and set of build tags required.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Boltnd

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

Boltnd holds opt-in bolt features that are externally implemented for lnd.

func NewBoltnd

func NewBoltnd(opts ...ConfigOption) (*Boltnd, error)

NewBoltnd returns a new external boltnd implementation. Note that the lnd config provided must be fully initialized so that we can setup our logging.

func (*Boltnd) Permissions

func (b *Boltnd) Permissions() map[string][]bakery.Op

Permissions returns all permissions for which boltnd's external validator is responsible.

NOTE: This is part of the lnd.ExternalValidator interface.

func (*Boltnd) RegisterGrpcSubserver

func (b *Boltnd) RegisterGrpcSubserver(server *grpc.Server) error

RegisterGrpcSubserver is a callback on the lnd.SubserverConfig struct that is called once lnd has initialized its main gRPC server instance. It gives the daemons (or external subservers) the possibility to register themselves to the same server instance.

NOTE: This is part of the lnd.GrpcRegistrar interface.

func (*Boltnd) Start

func (b *Boltnd) Start() error

Start starts the boltnd implementation.

func (*Boltnd) Stop

func (b *Boltnd) Stop() error

Stop shuts down the boltnd implementation.

func (*Boltnd) ValidateMacaroon

func (b *Boltnd) ValidateMacaroon(_ context.Context,
	_ []bakery.Op, _ 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 lnd.ExternalValidator interface.

type Config

type Config struct {
	// LndClientCfg provides configuration
	LndClientCfg *lndclient.LndServicesConfig

	// SetupLogger is used to register our loggers with a top level logger.
	SetupLogger func(prefix string, register LogRegistration)

	// RequestShutdown is an optional closure to request clean shutdown
	// from the calling entity if the boltnd instance errors out.
	RequestShutdown func()

	// LNDRetires is the number of times we try to connect to lnd's grpc
	// server (with backoff set by LNDWait) before exiting with an error.
	// This value should be set to 0 if we want to immediately exit if
	// we can't successfully connect.
	LNDRetires uint8

	// LNDWait is the amount of time to wait between retries to connect to
	// lnd's grpc server.
	LNDWait time.Duration
}

Config contains the configuration required for boltnd.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default config.

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures that we have all the required config values set.

type ConfigOption

type ConfigOption func(*Config) error

ConfigOption is the function signature used for functional options that update config.

func OptionLNDClient

func OptionLNDClient(lndClientCfg *lndclient.LndServicesConfig) ConfigOption

OptionLNDClient sets the lnd client config in our top level config.

func OptionLNDConfig

func OptionLNDConfig(cfg *lnd.Config) ConfigOption

OptionLNDConfig returns a functional option that will use lnd's internal config struct to create the lndclient config for our lndclient config.

func OptionLNDLogger

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

OptionLNDLogger uses lnd's root logger and interceptor to register our logs.

func OptionRequestShutdown

func OptionRequestShutdown(s func()) ConfigOption

OptionRequestShutdown provides a closure that will gracefully shutdown the calling code if boltnd exits with an error.

func OptionSetupLogger

func OptionSetupLogger(setup func(string, LogRegistration)) ConfigOption

OptionSetupLogger sets the setup logger function in our config.

type LogRegistration

type LogRegistration func(logger btclog.Logger)

LogRegistration is the function signature used to register loggers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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