chainreg

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDecredMinHTLCInMAtoms is the default smallest value htlc this
	// node will accept. This value is proposed in the channel open
	// sequence and cannot be changed during the life of the channel.
	//
	// All forwarded payments are subjected to the min htlc constraint of
	// the routing policy of the outgoing channel. This implicitly controls
	// the minimum htlc value on the incoming channel too.
	DefaultDecredMinHTLCInMAtoms = lnwire.MilliAtom(1000)

	// DefaultDecredMinHTLCOutMAtoms is the default minimum htlc value that
	// we require for sending out htlcs. Our channel peer may have a lower
	// min htlc channel parameter, but we - by default - don't forward
	// anything under the value defined here.
	DefaultDecredMinHTLCOutMAtoms = lnwire.MilliAtom(1000)

	// DefaultDecredBaseFeeMAtoms is the default forwarding base fee.
	DefaultDecredBaseFeeMAtoms = lnwire.MilliAtom(1000)

	// DefaultDecredFeeRate is the default forwarding fee rate.
	DefaultDecredFeeRate = lnwire.MilliAtom(1)

	// DefaultDecredTimeLockDelta is the default forwarding time lock
	// delta.
	DefaultDecredTimeLockDelta = 80

	// DefaultDecredStaticFeePerKB is the fee rate of 10000 atom/kB
	DefaultDecredStaticFeePerKB = chainfee.AtomPerKByte(1e4)

	// DefaultDecredStaticMinRelayFeeRate is the min relay fee used for
	// static estimators.
	DefaultDecredStaticMinRelayFeeRate = chainfee.FeePerKBFloor
)
View Source
const Subsystem = "CHRE"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (

	// ChainDNSSeeds is a map of a chain's hash to the set of DNS seeds
	// that will be use to bootstrap peers upon first startup.
	//
	// The first item in the array is the primary host we'll use to attempt
	// the SRV lookup we require. If we're unable to receive a response
	// over UDP, then we'll fall back to manual TCP resolution. The second
	// item in the array is a special A record that we'll query in order to
	// receive the IP address of the current authoritative DNS server for
	// the network seed.
	//
	// TODO(roasbeef): extend and collapse these and chainparams.go into
	// struct like chaincfg.Params
	ChainDNSSeeds = map[chainhash.Hash][][2]string{
		// contains filtered or unexported fields
	}
)
View Source
var DecredMainNetParams = DecredNetParams{
	Params:   chaincfg.MainNetParams(),
	RPCPort:  "9109",
	CoinType: keychain.CoinTypeDecred,
	DcrwPort: "9111",
}

DecredMainNetParams contains parameters specific to the current Decred mainnet.

View Source
var DecredSimNetParams = DecredNetParams{
	Params:   chaincfg.SimNetParams(),
	RPCPort:  "19556",
	CoinType: keychain.CoinTypeTestnet,
	DcrwPort: "19558",
}

decredSimNetParams contains parameters specific to the simulation test network.

View Source
var DecredTestNetParams = DecredNetParams{
	Params:   chaincfg.TestNet3Params(),
	RPCPort:  "19109",
	CoinType: keychain.CoinTypeTestnet,
	DcrwPort: "19111",
}

decredTestNetParams contains parameters specific to the 3rd version of the test network.

View Source
var RegTestNetParams = DecredNetParams{
	Params:   chaincfg.RegNetParams(),
	RPCPort:  "19334",
	CoinType: keychain.CoinTypeTestnet,
}

regTestNetParams contains parameters specific to a local regtest network.

Functions

func DisableLog

func DisableLog()

DisableLog disables all logging output.

func GenDefaultDcrConstraints

func GenDefaultDcrConstraints() channeldb.ChannelConstraints

GenDefaultDcrChannelConstraints generates the default set of channel constraints that are to be used when funding a Decred channel.

func IsTestnet

func IsTestnet(params *DecredNetParams) bool

IsTestnet tests if the given params correspond to a testnet parameter configuration.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type ChainCode

type ChainCode uint32

ChainCode is an enum-like structure for keeping track of the chains currently supported within lnd.

const (
	// DecredChain is Decred's chain.
	DecredChain ChainCode = iota
)

func (ChainCode) String

func (c ChainCode) String() string

String returns a string representation of the target ChainCode.

type ChainControl

type ChainControl struct {
	// ChainIO represents an abstraction over a source that can query the blockchain.
	ChainIO lnwallet.BlockChainIO

	// HealthCheck is a function which can be used to send a low-cost, fast
	// query to the chain backend to ensure we still have access to our
	// node.
	HealthCheck func() error

	// FeeEstimator is used to estimate an optimal fee for transactions important to us.
	FeeEstimator chainfee.Estimator

	// Signer is used to provide signatures over things like transactions.
	Signer input.Signer

	// KeyRing represents a set of keys that we have the private keys to.
	KeyRing keychain.SecretKeyRing

	// Wc is an abstraction over some basic wallet commands. This base set of commands
	// will be provided to the Wallet *LightningWallet raw pointer below.
	Wc lnwallet.WalletController

	// MsgSigner is used to sign arbitrary messages.
	MsgSigner lnwallet.MessageSigner

	// ChainNotifier is used to receive blockchain events that we are interested in.
	ChainNotifier chainntnfs.ChainNotifier

	// ChainView is used in the router for maintaining an up-to-date graph.
	ChainView chainview.FilteredChainView

	// Wallet is our LightningWallet that also contains the abstract Wc above. This wallet
	// handles all of the lightning operations.
	Wallet *lnwallet.LightningWallet

	// RoutingPolicy is the routing policy we have decided to use.
	RoutingPolicy htlcswitch.ForwardingPolicy

	// MinHtlcIn is the minimum HTLC we will accept.
	MinHtlcIn lnwire.MilliAtom
}

ChainControl couples the three primary interfaces lnd utilizes for a particular chain together. A single ChainControl instance will exist for all the chains lnd is currently active on.

func NewChainControl

func NewChainControl(cfg *Config) (*ChainControl, func(), error)

NewChainControl attempts to create a ChainControl instance according to the parameters in the passed configuration.

type ChainRegistry

type ChainRegistry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ChainRegistry keeps track of the current chains

func NewChainRegistry

func NewChainRegistry() *ChainRegistry

NewChainRegistry creates a new ChainRegistry.

func (*ChainRegistry) ActiveChains

func (c *ChainRegistry) ActiveChains() []ChainCode

ActiveChains returns a slice containing the active chains.

func (*ChainRegistry) LookupChain

func (c *ChainRegistry) LookupChain(targetChain ChainCode) (*ChainControl, bool)

LookupChain attempts to lookup an active ChainControl instance for the target chain.

func (*ChainRegistry) LookupChainByHash

func (c *ChainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*ChainControl, bool)

LookupChainByHash attempts to look up an active ChainControl which corresponds to the passed genesis hash.

func (*ChainRegistry) NumActiveChains

func (c *ChainRegistry) NumActiveChains() uint32

NumActiveChains returns the total number of active chains.

func (*ChainRegistry) PrimaryChain

func (c *ChainRegistry) PrimaryChain() ChainCode

PrimaryChain returns the primary chain for this running lnd instance. The primary chain is considered the "home base" while the other registered chains are treated as secondary chains.

func (*ChainRegistry) RegisterChain

func (c *ChainRegistry) RegisterChain(newChain ChainCode, cc *ChainControl)

RegisterChain assigns an active ChainControl instance to a target chain identified by its ChainCode.

func (*ChainRegistry) RegisterPrimaryChain

func (c *ChainRegistry) RegisterPrimaryChain(cc ChainCode)

RegisterPrimaryChain sets a target chain as the "home chain" for lnd.

type Config

type Config struct {
	// Decred defines the settings for the Decred chain.
	Decred *lncfg.Chain

	// PrimaryChain is a function that returns our primary chain via its
	// ChainCode.
	PrimaryChain func() ChainCode

	// HeightHintCacheQueryDisable is a boolean that disables height hint
	// queries if true.
	HeightHintCacheQueryDisable bool

	// DcrdMode defines settings for connecting to a dcrd instance.
	DcrdMode *lncfg.DcrdConfig

	// DcrwMode defines settings for connecting to a dcrwallet instance.
	DcrwMode *lncfg.DcrwalletConfig

	// LocalChanDB is a pointer to the local backing channel database.
	LocalChanDB *channeldb.DB

	// RemoteChanDB is a pointer to the remote backing channel database.
	RemoteChanDB *channeldb.DB

	// BlockCacheSize is the size (in bytes) of blocks kept in memory.
	BlockCacheSize uint64

	// PrivateWalletPw is the private wallet password to the underlying
	// btcwallet instance.
	PrivateWalletPw []byte

	// PublicWalletPw is the public wallet password to the underlying btcwallet
	// instance.
	PublicWalletPw []byte

	// Birthday specifies the time the wallet was initially created.
	Birthday time.Time

	// RecoveryWindow specifies the address look-ahead for which to scan when
	// restoring a wallet.
	RecoveryWindow uint32

	// WalletLoader is a pointer to an embedded wallet loader.
	WalletLoader *walletloader.Loader

	// Wallet is a pointer to the backing wallet instance.
	Wallet *wallet.Wallet

	// WalletConn is the grpc connection to a remote wallet when the chain
	// is running based on a remote wallet.
	WalletConn *grpc.ClientConn

	// WalletAccountNb is the root account from which the dcrlnd keys are
	// derived when running based on a remote wallet.
	WalletAccountNb int32

	// ActiveNetParams details the current chain we are on.
	ActiveNetParams DecredNetParams

	// FeeURL defines the URL for fee estimation we will use. This field is
	// optional.
	FeeURL string

	// Dialer is a function closure that will be used to establish outbound
	// TCP connections to chain network peers in the event of a pruned block being
	// requested.
	Dialer func(string) (net.Conn, error)

	// LoaderOptions holds functional wallet db loader options.
	LoaderOptions []walletloader.LoaderOption

	// CoinSelectionStrategy is the strategy that is used for selecting
	// coins when funding a transaction.
	CoinSelectionStrategy lnwallet.CoinSelectionStrategy
}

Config houses necessary fields that a chainControl instance needs to function.

type DecredNetParams

type DecredNetParams struct {
	*chaincfg.Params
	RPCPort  string
	CoinType uint32
	DcrwPort string
}

DecredNetParams couples the p2p parameters of a network with the corresponding RPC port of a daemon running on the particular network.

Jump to

Keyboard shortcuts

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