Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyLitecoinParams(params *BitcoinNetParams, litecoinParams *LitecoinNetParams)
- func DisableLog()
- func IsTestnet(params *BitcoinNetParams) bool
- func UseLogger(logger btclog.Logger)
- type BitcoinNetParams
- type ChainCode
- type ChainControl
- type ChainRegistry
- func (c *ChainRegistry) ActiveChains() []ChainCode
- func (c *ChainRegistry) LookupChain(targetChain ChainCode) (*ChainControl, bool)
- func (c *ChainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*ChainControl, bool)
- func (c *ChainRegistry) NumActiveChains() uint32
- func (c *ChainRegistry) PrimaryChain() ChainCode
- func (c *ChainRegistry) RegisterChain(newChain ChainCode, cc *ChainControl)
- func (c *ChainRegistry) RegisterPrimaryChain(cc ChainCode)
- type Config
- type LitecoinNetParams
Constants ¶
const ( // DefaultBitcoinMinHTLCInMSat 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. DefaultBitcoinMinHTLCInMSat = lnwire.MilliSatoshi(1) // DefaultBitcoinMinHTLCOutMSat 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. DefaultBitcoinMinHTLCOutMSat = lnwire.MilliSatoshi(1000) // DefaultBitcoinBaseFeeMSat is the default forwarding base fee. DefaultBitcoinBaseFeeMSat = lnwire.MilliSatoshi(1000) // DefaultBitcoinFeeRate is the default forwarding fee rate. DefaultBitcoinFeeRate = lnwire.MilliSatoshi(1) // DefaultBitcoinTimeLockDelta is the default forwarding time lock // delta. DefaultBitcoinTimeLockDelta = 40 DefaultLitecoinMinHTLCInMSat = lnwire.MilliSatoshi(1) DefaultLitecoinMinHTLCOutMSat = lnwire.MilliSatoshi(1000) DefaultLitecoinBaseFeeMSat = lnwire.MilliSatoshi(1000) DefaultLitecoinFeeRate = lnwire.MilliSatoshi(1) DefaultLitecoinTimeLockDelta = 576 DefaultLitecoinDustLimit = btcutil.Amount(54600) // DefaultBitcoinStaticFeePerKW is the fee rate of 50 sat/vbyte // expressed in sat/kw. DefaultBitcoinStaticFeePerKW = chainfee.SatPerKWeight(12500) // DefaultBitcoinStaticMinRelayFeeRate is the min relay fee used for // static estimators. DefaultBitcoinStaticMinRelayFeeRate = chainfee.FeePerKwFloor // DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte // expressed in sat/kw. DefaultLitecoinStaticFeePerKW = chainfee.SatPerKWeight(50000) // BtcToLtcConversionRate is a fixed ratio used in order to scale up // payments when running on the Litecoin chain. BtcToLtcConversionRate = 60 )
const Subsystem = "CHRE"
Subsystem defines the logging code for this subsystem.
Variables ¶
var ( // BitcoinTestnetGenesis is the genesis hash of Bitcoin's testnet // chain. BitcoinTestnetGenesis = chainhash.Hash([chainhash.HashSize]byte{ 0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00, }) // BitcoinMainnetGenesis is the genesis hash of Bitcoin's main chain. BitcoinMainnetGenesis = chainhash.Hash([chainhash.HashSize]byte{ 0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, }) // 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{ BitcoinMainnetGenesis: { { "nodes.lightning.directory", "soa.nodes.lightning.directory", }, { "lseed.bitcoinstats.com", }, }, BitcoinTestnetGenesis: { { "test.nodes.lightning.directory", "soa.nodes.lightning.directory", }, }, LitecoinMainnetGenesis: { { "ltc.nodes.lightning.directory", "soa.nodes.lightning.directory", }, }, } )
var BitcoinMainNetParams = BitcoinNetParams{ Params: &bitcoinCfg.MainNetParams, RPCPort: "8334", CoinType: keychain.CoinTypeBitcoin, }
BitcoinMainNetParams contains parameters specific to the current Bitcoin mainnet.
var BitcoinRegTestNetParams = BitcoinNetParams{ Params: &bitcoinCfg.RegressionNetParams, RPCPort: "18334", CoinType: keychain.CoinTypeTestnet, }
BitcoinRegTestNetParams contains parameters specific to a local bitcoin regtest network.
var BitcoinSimNetParams = BitcoinNetParams{ Params: &bitcoinCfg.SimNetParams, RPCPort: "18556", CoinType: keychain.CoinTypeTestnet, }
BitcoinSimNetParams contains parameters specific to the simulation test network.
var BitcoinTestNetParams = BitcoinNetParams{ Params: &bitcoinCfg.TestNet3Params, RPCPort: "18334", CoinType: keychain.CoinTypeTestnet, }
BitcoinTestNetParams contains parameters specific to the 3rd version of the test network.
var DefaultBtcChannelConstraints = channeldb.ChannelConstraints{ DustLimit: lnwallet.DefaultDustLimit(), MaxAcceptedHtlcs: input.MaxHTLCNumber / 2, }
DefaultBtcChannelConstraints is the default set of channel constraints that are meant to be used when initially funding a Bitcoin channel.
TODO(halseth): make configurable at startup?
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.
var LitecoinMainNetParams = LitecoinNetParams{ Params: &litecoinCfg.MainNetParams, RPCPort: "9334", CoinType: keychain.CoinTypeLitecoin, }
LitecoinMainNetParams contains the parameters specific to the current Litecoin mainnet.
var LitecoinRegTestNetParams = LitecoinNetParams{ Params: &litecoinCfg.RegressionNetParams, RPCPort: "18334", CoinType: keychain.CoinTypeTestnet, }
LitecoinRegTestNetParams contains parameters specific to a local litecoin regtest network.
var LitecoinSimNetParams = LitecoinNetParams{ Params: &litecoinCfg.TestNet4Params, RPCPort: "18556", CoinType: keychain.CoinTypeTestnet, }
LitecoinSimNetParams contains parameters specific to the simulation test network.
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 *BitcoinNetParams, litecoinParams *LitecoinNetParams)
ApplyLitecoinParams applies the relevant chain configuration parameters that differ for litecoin to the chain parameters typed for btcsuite derivation. This function is used in place of using something like interface{} to abstract over _which_ chain (or fork) the parameters are for.
func IsTestnet ¶
func IsTestnet(params *BitcoinNetParams) bool
IsTestnet tests if the givern params correspond to a testnet parameter configuration.
Types ¶
type BitcoinNetParams ¶
type BitcoinNetParams struct { *bitcoinCfg.Params RPCPort string CoinType uint32 }
BitcoinNetParams 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 lnd.
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.MilliSatoshi }
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, 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 btcd full-node, another backed by a running bitcoind 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 ¶
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 { // Bitcoin defines settings for the Bitcoin chain. Bitcoin *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 // BitcoindMode defines settings for connecting to a bitcoind node. BitcoindMode *lncfg.Bitcoind // LitecoindMode defines settings for connecting to a litecoind node. LitecoindMode *lncfg.Bitcoind // BtcdMode defines settings for connecting to a btcd node. BtcdMode *lncfg.Btcd // LtcdMode defines settings for connecting to an ltcd node. LtcdMode *lncfg.Btcd // 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 // 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 // Wallet is a pointer to the backing wallet instance. Wallet *wallet.Wallet // 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 BitcoinNetParams // FeeURL defines the URL for fee estimation we will use. This field is // optional. FeeURL string // DBTimeOut specifies the timeout value to use when opening the wallet // database. DBTimeOut time.Duration }
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.