Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func IsTestnet(params *BitcoinNetParams) bool
- func UseLogger(logger btclog.Logger)
- type BitcoinNetParams
- type ChainControl
- type Config
- type NoChainBackend
- func (n *NoChainBackend) DisconnectedBlocks() <-chan *chainview.FilteredBlock
- func (n *NoChainBackend) EstimateFeePerKW(uint32) (chainfee.SatPerKWeight, error)
- func (n *NoChainBackend) FilterBlock(*chainhash.Hash) (*chainview.FilteredBlock, error)
- func (n *NoChainBackend) FilteredBlocks() <-chan *chainview.FilteredBlock
- func (n *NoChainBackend) RegisterBlockEpochNtfn(*chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error)
- func (n *NoChainBackend) RegisterConfirmationsNtfn(*chainhash.Hash, []byte, uint32, uint32, ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error)
- func (n *NoChainBackend) RegisterSpendNtfn(*wire.OutPoint, []byte, uint32) (*chainntnfs.SpendEvent, error)
- func (n *NoChainBackend) RelayFeePerKW() chainfee.SatPerKWeight
- func (n *NoChainBackend) Start() error
- func (n *NoChainBackend) Started() bool
- func (n *NoChainBackend) Stop() error
- func (n *NoChainBackend) UpdateFilter([]channeldb.EdgePoint, uint32) error
- type NoChainSource
- func (n *NoChainSource) BackEnd() string
- func (n *NoChainSource) BlockStamp() (*waddrmgr.BlockStamp, error)
- func (n *NoChainSource) FilterBlocks(*chain.FilterBlocksRequest) (*chain.FilterBlocksResponse, error)
- func (n *NoChainSource) GetBestBlock() (*chainhash.Hash, int32, error)
- func (n *NoChainSource) GetBlock(*chainhash.Hash) (*wire.MsgBlock, error)
- func (n *NoChainSource) GetBlockHash(int64) (*chainhash.Hash, error)
- func (n *NoChainSource) GetBlockHeader(*chainhash.Hash) (*wire.BlockHeader, error)
- func (n *NoChainSource) IsCurrent() bool
- func (n *NoChainSource) Notifications() <-chan interface{}
- func (n *NoChainSource) NotifyBlocks() error
- func (n *NoChainSource) NotifyReceived([]btcutil.Address) error
- func (n *NoChainSource) Rescan(*chainhash.Hash, []btcutil.Address, map[wire.OutPoint]btcutil.Address) error
- func (n *NoChainSource) SendRawTransaction(*wire.MsgTx, bool) (*chainhash.Hash, error)
- func (n *NoChainSource) Start() error
- func (n *NoChainSource) Stop()
- func (n *NoChainSource) TestMempoolAccept([]*wire.MsgTx, float64) ([]*btcjson.TestMempoolAcceptResult, error)
- func (n *NoChainSource) WaitForShutdown()
- type PartialChainControl
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 = 80 // 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 // DefaultMinOutboundPeers is the min number of connected // outbound peers the chain backend should have to maintain a // healthy connection to the network. DefaultMinOutboundPeers = 6 )
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, }) // BitcoinSignetGenesis is the genesis hash of Bitcoin's signet chain. BitcoinSignetGenesis = 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, }) // 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, }) // 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", }, }, BitcoinSignetGenesis: { { "ln.signet.secp.tech", }, }, } )
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 BitcoinSigNetParams = BitcoinNetParams{ Params: &bitcoinCfg.SigNetParams, RPCPort: "38332", CoinType: keychain.CoinTypeTestnet, }
BitcoinSigNetParams contains parameters specific to the signet test 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.
Functions ¶
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 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 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(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 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 Config ¶
type Config struct { // Bitcoin defines settings for the Bitcoin chain. Bitcoin *lncfg.Chain // 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 // BtcdMode defines settings for connecting to a btcd node. BtcdMode *lncfg.Btcd // 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 BitcoinNetParams // Deprecated: Use Fee.URL. FeeURL defines the URL for fee estimation // we will use. This field is optional. FeeURL string // Fee defines settings for the web fee estimator. This field is // optional. Fee *lncfg.Fee // Dialer is a function closure that will be used to establish outbound // TCP connections to Bitcoin 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 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 (n *NoChainBackend) FilterBlock(*chainhash.Hash) (*chainview.FilteredBlock, error)
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.NotifierOption) (*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 ¶
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 (n *NoChainSource) FilterBlocks( *chain.FilterBlocksRequest) (*chain.FilterBlocksResponse, error)
func (*NoChainSource) GetBestBlock ¶
func (n *NoChainSource) GetBestBlock() (*chainhash.Hash, int32, 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([]btcutil.Address) error
func (*NoChainSource) SendRawTransaction ¶
func (*NoChainSource) Start ¶
func (n *NoChainSource) Start() error
func (*NoChainSource) Stop ¶
func (n *NoChainSource) Stop()
func (*NoChainSource) TestMempoolAccept ¶
func (n *NoChainSource) TestMempoolAccept([]*wire.MsgTx, float64) ([]*btcjson.TestMempoolAcceptResult, error)
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 // BestBlockTracker is used to maintain a view of the global // chain state that changes over time BestBlockTracker *chainntnfs.BestBlockTracker // MempoolNotifier is used to watch for spending events happened in // mempool. MempoolNotifier chainntnfs.MempoolWatcher // 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 models.ForwardingPolicy // MinHtlcIn is the minimum HTLC we will accept. MinHtlcIn lnwire.MilliSatoshi }
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.