chainreg

package
v0.0.0-...-bd4bb24 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBrocoinMinHTLCInMSat 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. It is 1 msat by
	// default to allow maximum flexibility in deciding what size payments
	// to forward.
	//
	// 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.
	DefaultBrocoinMinHTLCInMSat = lnwire.MilliBronees(1)

	// DefaultBrocoinMinHTLCOutMSat 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.
	DefaultBrocoinMinHTLCOutMSat = lnwire.MilliBronees(1000)

	// DefaultBrocoinBaseFeeMSat is the default forwarding base fee.
	DefaultBrocoinBaseFeeMSat = lnwire.MilliBronees(1000)

	// DefaultBrocoinFeeRate is the default forwarding fee rate.
	DefaultBrocoinFeeRate = lnwire.MilliBronees(1)

	// DefaultBrocoinTimeLockDelta is the default forwarding time lock
	// delta.
	DefaultBrocoinTimeLockDelta = 40

	DefaultLitecoinMinHTLCInMSat  = lnwire.MilliBronees(1)
	DefaultLitecoinMinHTLCOutMSat = lnwire.MilliBronees(1000)
	DefaultLitecoinBaseFeeMSat    = lnwire.MilliBronees(1000)
	DefaultLitecoinFeeRate        = lnwire.MilliBronees(1)
	DefaultLitecoinTimeLockDelta  = 576
	DefaultLitecoinDustLimit      = bronutil.Amount(54600)

	// DefaultBrocoinStaticFeePerKW is the fee rate of 50 sat/vbyte
	// expressed in sat/kw.
	DefaultBrocoinStaticFeePerKW = chainfee.SatPerKWeight(12500)

	// DefaultBrocoinStaticMinRelayFeeRate is the min relay fee used for
	// static estimators.
	DefaultBrocoinStaticMinRelayFeeRate = chainfee.FeePerKwFloor

	// DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte
	// expressed in sat/kw.
	DefaultLitecoinStaticFeePerKW = chainfee.SatPerKWeight(50000)

	// BronToLtcConversionRate is a fixed ratio used in order to scale up
	// payments when running on the Litecoin chain.
	BronToLtcConversionRate = 60
)
View Source
const Subsystem = "CHRE"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (
	// BrocoinTestnetGenesis is the genesis hash of Brocoin's testnet
	// chain.
	BrocoinTestnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
		0xce, 0xeb, 0x1a, 0x38, 0x06, 0xf0, 0x71, 0x0c,
		0xda, 0x62, 0xbd, 0x49, 0x32, 0x8d, 0x70, 0x62,
		0xb1, 0x0c, 0xca, 0x75, 0xd1, 0xd8, 0x16, 0x9f,
		0xa9, 0x9e, 0xed, 0x16, 0xfa, 0x0c, 0x00, 0x00,
	})

	// BrocoinSignetGenesis is the genesis hash of Brocoin's signet chain.
	BrocoinSignetGenesis = chainhash.Hash([chainhash.HashSize]byte{
		0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80, 0xa4,
		0x77, 0xa0, 0x63, 0xaf, 0x32, 0xb2, 0xbb, 0xc9,
		0x7c, 0x9f, 0xf9, 0xf0, 0x1f, 0x2c, 0x42, 0x25,
		0xe9, 0x73, 0x98, 0x81, 0x08, 0x00, 0x00, 0x00,
	})

	// BrocoinMainnetGenesis is the genesis hash of Brocoin's main chain.
	BrocoinMainnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
		0xd2, 0x28, 0x0d, 0x8c, 0xf4, 0x3a, 0x3e, 0xfd,
		0x9a, 0x51, 0x41, 0x4b, 0x15, 0xbf, 0x6a, 0xb0,
		0x2b, 0x1c, 0x12, 0xfb, 0x78, 0xd6, 0xb6, 0x9e,
		0x63, 0xf8, 0x88, 0xc5, 0xe3, 0x18, 0xbf, 0x05,
	})

	// LitecoinTestnetGenesis is the genesis hash of Litecoin's testnet4
	// chain.
	LitecoinTestnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
		0xa0, 0x29, 0x3e, 0x4e, 0xeb, 0x3d, 0xa6, 0xe6,
		0xf5, 0x6f, 0x81, 0xed, 0x59, 0x5f, 0x57, 0x88,
		0x0d, 0x1a, 0x21, 0x56, 0x9e, 0x13, 0xee, 0xfd,
		0xd9, 0x51, 0x28, 0x4b, 0x5a, 0x62, 0x66, 0x49,
	})

	// LitecoinMainnetGenesis is the genesis hash of Litecoin's main chain.
	LitecoinMainnetGenesis = chainhash.Hash([chainhash.HashSize]byte{
		0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19, 0x1a,
		0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97, 0x9d, 0xc9,
		0x98, 0x6e, 0x0f, 0x19, 0x25, 0x1e, 0xda, 0xba,
		0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12,
	})

	// 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{
		BrocoinMainnetGenesis: {
			{
				"207.180.196.129",
			},
			{},
		},

		BrocoinTestnetGenesis: {
			{
				"207.180.196.129",
			},
		},

		BrocoinSignetGenesis: {
			{
				"ln.signet.secp.tech",
			},
		},

		LitecoinMainnetGenesis: {
			{
				"ltc.nodes.lightning.directory",
				"soa.nodes.lightning.directory",
			},
		},
	}
)
View Source
var BrocoinMainNetParams = BrocoinNetParams{
	Params:   &brocoinCfg.MainNetParams,
	RPCPort:  "8360",
	CoinType: keychain.CoinTypeBrocoin,
}

BrocoinMainNetParams contains parameters specific to the current Brocoin mainnet.

View Source
var BrocoinRegTestNetParams = BrocoinNetParams{
	Params:   &brocoinCfg.RegressionNetParams,
	RPCPort:  "18871",
	CoinType: keychain.CoinTypeTestnet,
}

BrocoinRegTestNetParams contains parameters specific to a local brocoin regtest network.

View Source
var BrocoinSigNetParams = BrocoinNetParams{
	Params:   &brocoinCfg.SigNetParams,
	RPCPort:  "38332",
	CoinType: keychain.CoinTypeTestnet,
}

BrocoinSigNetParams contains parameters specific to the signet test network.

View Source
var BrocoinSimNetParams = BrocoinNetParams{
	Params:   &brocoinCfg.SimNetParams,
	RPCPort:  "18556",
	CoinType: keychain.CoinTypeTestnet,
}

BrocoinSimNetParams contains parameters specific to the simulation test network.

View Source
var BrocoinTestNetParams = BrocoinNetParams{
	Params:   &brocoinCfg.TestNet3Params,
	RPCPort:  "18740",
	CoinType: keychain.CoinTypeTestnet,
}

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

View Source
var DefaultLtcChannelConstraints = channeldb.ChannelConstraints{
	DustLimit:        DefaultLitecoinDustLimit,
	MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
}

DefaultLtcChannelConstraints is the default set of channel constraints that are meant to be used when initially funding a Litecoin channel.

View Source
var LitecoinMainNetParams = LitecoinNetParams{
	Params:   &litecoinCfg.MainNetParams,
	RPCPort:  "9334",
	CoinType: keychain.CoinTypeLitecoin,
}

LitecoinMainNetParams contains the parameters specific to the current Litecoin mainnet.

View Source
var LitecoinRegTestNetParams = LitecoinNetParams{
	Params:   &litecoinCfg.RegressionNetParams,
	RPCPort:  "18334",
	CoinType: keychain.CoinTypeTestnet,
}

LitecoinRegTestNetParams contains parameters specific to a local litecoin regtest network.

View Source
var LitecoinSimNetParams = LitecoinNetParams{
	Params:   &litecoinCfg.TestNet4Params,
	RPCPort:  "18556",
	CoinType: keychain.CoinTypeTestnet,
}

LitecoinSimNetParams contains parameters specific to the simulation test network.

View Source
var LitecoinTestNetParams = LitecoinNetParams{
	Params:   &litecoinCfg.TestNet4Params,
	RPCPort:  "19334",
	CoinType: keychain.CoinTypeTestnet,
}

LitecoinTestNetParams contains parameters specific to the 4th version of the test network.

Functions

func ApplyLitecoinParams

func ApplyLitecoinParams(params *BrocoinNetParams,
	litecoinParams *LitecoinNetParams)

ApplyLitecoinParams applies the relevant chain configuration parameters that differ for litecoin to the chain parameters typed for brsuite derivation. This function is used in place of using something like interface{} to abstract over _which_ chain (or fork) the parameters are for.

func DisableLog

func DisableLog()

DisableLog disables all logging output.

func GenDefaultBronConstraints

func GenDefaultBronConstraints() channeldb.ChannelConstraints

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

func IsTestnet

func IsTestnet(params *BrocoinNetParams) bool

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

func UseLogger

func UseLogger(logger bronlog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type BrocoinNetParams

type BrocoinNetParams struct {
	*brocoinCfg.Params
	RPCPort  string
	CoinType uint32
}

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

type ChainCode

type ChainCode uint32

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

const (
	// BrocoinChain is Brocoin's chain.
	BrocoinChain ChainCode = iota

	// LitecoinChain is Litecoin's chain.
	LitecoinChain
)

func (ChainCode) String

func (c ChainCode) String() string

String returns a string representation of the target ChainCode.

type ChainControl

type ChainControl struct {
	// PartialChainControl is the part of the chain control that was
	// initialized purely from the configuration and doesn't contain any
	// wallet related elements.
	*PartialChainControl

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

	// 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

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

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

func NewChainControl

func NewChainControl(walletConfig lnwallet.Config,
	msgSigner lnwallet.MessageSigner,
	pcc *PartialChainControl) (*ChainControl, func(), error)

NewChainControl attempts to create a ChainControl instance according to the parameters in the passed configuration. Currently three branches of ChainControl instances exist: one backed by a running brond full-node, another backed by a running brocoind full-node, and the other backed by a running neutrino light client instance. When running with a neutrino light client instance, `neutrinoCS` must be non-nil.

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 broln 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 broln.

type Config

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

	// Litecoin defines settings for the Litecoin chain.
	Litecoin *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

	// NeutrinoMode defines settings for connecting to a neutrino
	// light-client.
	NeutrinoMode *lncfg.Neutrino

	// BrocoindMode defines settings for connecting to a brocoind node.
	BrocoindMode *lncfg.Brocoind

	// LitecoindMode defines settings for connecting to a litecoind node.
	LitecoindMode *lncfg.Brocoind

	// BrondMode defines settings for connecting to a brond node.
	BrondMode *lncfg.Brond

	// LtcdMode defines settings for connecting to an ltcd node.
	LtcdMode *lncfg.Brond

	// HeightHintDB is a pointer to the database that stores the height
	// hints.
	HeightHintDB kvdb.Backend

	// ChanStateDB is a pointer to the database that stores the channel
	// state.
	ChanStateDB *channeldb.ChannelStateDB

	// BlockCache is the main cache for storing block information.
	BlockCache *blockcache.BlockCache

	// WalletUnlockParams are the parameters that were used for unlocking
	// the main wallet.
	WalletUnlockParams *walletunlocker.WalletUnlockParams

	// NeutrinoCS is a pointer to a neutrino ChainService. Must be non-nil
	// if using neutrino.
	NeutrinoCS *neutrino.ChainService

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

	// 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 Brocoin peers in the event of a pruned block being
	// requested.
	Dialer chain.Dialer
}

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

type LitecoinNetParams

type LitecoinNetParams struct {
	*litecoinCfg.Params
	RPCPort  string
	CoinType uint32
}

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

type NoChainBackend

type NoChainBackend struct {
}

NoChainBackend is a mock implementation of the following interfaces:

  • chainview.FilteredChainView
  • chainntnfs.ChainNotifier
  • chainfee.Estimator

func (*NoChainBackend) DisconnectedBlocks

func (n *NoChainBackend) DisconnectedBlocks() <-chan *chainview.FilteredBlock

func (*NoChainBackend) EstimateFeePerKW

func (n *NoChainBackend) EstimateFeePerKW(uint32) (chainfee.SatPerKWeight,
	error)

func (*NoChainBackend) FilterBlock

func (*NoChainBackend) FilteredBlocks

func (n *NoChainBackend) FilteredBlocks() <-chan *chainview.FilteredBlock

func (*NoChainBackend) RegisterBlockEpochNtfn

func (n *NoChainBackend) RegisterBlockEpochNtfn(
	*chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)

func (*NoChainBackend) RegisterConfirmationsNtfn

func (n *NoChainBackend) RegisterConfirmationsNtfn(*chainhash.Hash, []byte,
	uint32, uint32) (*chainntnfs.ConfirmationEvent, error)

func (*NoChainBackend) RegisterSpendNtfn

func (n *NoChainBackend) RegisterSpendNtfn(*wire.OutPoint, []byte,
	uint32) (*chainntnfs.SpendEvent, error)

func (*NoChainBackend) RelayFeePerKW

func (n *NoChainBackend) RelayFeePerKW() chainfee.SatPerKWeight

func (*NoChainBackend) Start

func (n *NoChainBackend) Start() error

func (*NoChainBackend) Started

func (n *NoChainBackend) Started() bool

func (*NoChainBackend) Stop

func (n *NoChainBackend) Stop() error

func (*NoChainBackend) UpdateFilter

func (n *NoChainBackend) UpdateFilter([]channeldb.EdgePoint, uint32) error

type NoChainSource

type NoChainSource struct {
	BestBlockTime time.Time
	// contains filtered or unexported fields
}

NoChainSource is a mock implementation of chain.Interface. The mock is designed to return static values where necessary to make any caller believe the chain is fully synced to virtual block height 1 (hash 0x0000..0001). That should avoid calls to other methods completely since they are only used for advancing the chain forward.

func (*NoChainSource) BackEnd

func (n *NoChainSource) BackEnd() string

func (*NoChainSource) BlockStamp

func (n *NoChainSource) BlockStamp() (*waddrmgr.BlockStamp, error)

func (*NoChainSource) FilterBlocks

func (*NoChainSource) GetBestBlock

func (n *NoChainSource) GetBestBlock() (*chainhash.Hash, int32, error)

func (*NoChainSource) GetBlock

func (n *NoChainSource) GetBlock(*chainhash.Hash) (*wire.MsgBlock, error)

func (*NoChainSource) GetBlockHash

func (n *NoChainSource) GetBlockHash(int64) (*chainhash.Hash, error)

func (*NoChainSource) GetBlockHeader

func (n *NoChainSource) GetBlockHeader(*chainhash.Hash) (*wire.BlockHeader,
	error)

func (*NoChainSource) IsCurrent

func (n *NoChainSource) IsCurrent() bool

func (*NoChainSource) Notifications

func (n *NoChainSource) Notifications() <-chan interface{}

func (*NoChainSource) NotifyBlocks

func (n *NoChainSource) NotifyBlocks() error

func (*NoChainSource) NotifyReceived

func (n *NoChainSource) NotifyReceived([]bronutil.Address) error

func (*NoChainSource) Rescan

func (*NoChainSource) SendRawTransaction

func (n *NoChainSource) SendRawTransaction(*wire.MsgTx, bool) (*chainhash.Hash,
	error)

func (*NoChainSource) Start

func (n *NoChainSource) Start() error

func (*NoChainSource) Stop

func (n *NoChainSource) Stop()

func (*NoChainSource) WaitForShutdown

func (n *NoChainSource) WaitForShutdown()

type PartialChainControl

type PartialChainControl struct {
	// Cfg is the configuration that was used to create the partial chain
	// control.
	Cfg *Config

	// 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

	// 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

	// ChainSource is the primary chain interface. This is used to operate
	// the wallet and do things such as rescanning, sending transactions,
	// notifications for received funds, etc.
	ChainSource chain.Interface

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

	// MinHtlcIn is the minimum HTLC we will accept.
	MinHtlcIn lnwire.MilliBronees

	// ChannelConstraints is the set of default constraints that will be
	// used for any incoming or outgoing channel reservation requests.
	ChannelConstraints channeldb.ChannelConstraints
}

PartialChainControl contains all the primary interfaces of the chain control that can be purely constructed from the global configuration. No wallet instance is required for constructing this partial state.

func NewPartialChainControl

func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error)

NewPartialChainControl creates a new partial chain control that contains all the parts that can be purely constructed from the passed in global configuration and doesn't need any wallet instance yet.

Jump to

Keyboard shortcuts

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