config: allow web fee estimation on regtest
This commit is contained in:
parent
dae0e2194d
commit
fc3fd26a3d
@ -2,6 +2,7 @@ package lnd
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@ -249,16 +250,15 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If the user provided an API for fee estimation, activate it now.
|
||||
// Map the deprecated neutrino feeurl flag to the general fee
|
||||
// url.
|
||||
if cfg.NeutrinoMode.FeeURL != "" {
|
||||
ltndLog.Infof("Using API fee estimator!")
|
||||
if cfg.FeeURL != "" {
|
||||
return nil, errors.New("feeurl and " +
|
||||
"neutrino.feeurl are mutually exclusive")
|
||||
}
|
||||
|
||||
cc.feeEstimator = chainfee.NewWebAPIEstimator(
|
||||
chainfee.SparseConfFeeSource{
|
||||
URL: cfg.NeutrinoMode.FeeURL,
|
||||
},
|
||||
false,
|
||||
)
|
||||
cfg.FeeURL = cfg.NeutrinoMode.FeeURL
|
||||
}
|
||||
|
||||
walletConfig.ChainSource = chain.NewNeutrinoClient(
|
||||
@ -485,6 +485,23 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
||||
homeChainConfig.Node)
|
||||
}
|
||||
|
||||
// Override default fee estimator if an external service is specified.
|
||||
if cfg.FeeURL != "" {
|
||||
// Do not cache fees on regtest to make it easier to execute
|
||||
// manual or automated test cases.
|
||||
cacheFees := !cfg.Bitcoin.RegTest
|
||||
|
||||
ltndLog.Infof("Using external fee estimator %v: cached=%v",
|
||||
cfg.FeeURL, cacheFees)
|
||||
|
||||
cc.feeEstimator = chainfee.NewWebAPIEstimator(
|
||||
chainfee.SparseConfFeeSource{
|
||||
URL: cfg.FeeURL,
|
||||
},
|
||||
!cacheFees,
|
||||
)
|
||||
}
|
||||
|
||||
// Start fee estimator.
|
||||
if err := cc.feeEstimator.Start(); err != nil {
|
||||
return nil, err
|
||||
|
@ -210,6 +210,8 @@ type Config struct {
|
||||
MaxPendingChannels int `long:"maxpendingchannels" description:"The maximum number of incoming pending channels permitted per peer."`
|
||||
BackupFilePath string `long:"backupfilepath" description:"The target location of the channel backup file"`
|
||||
|
||||
FeeURL string `long:"feeurl" description:"Optional URL for external fee estimation. If no URL is specified, the method for fee estimation will depend on the chosen backend and network."`
|
||||
|
||||
Bitcoin *lncfg.Chain `group:"Bitcoin" namespace:"bitcoin"`
|
||||
BtcdMode *lncfg.Btcd `group:"btcd" namespace:"btcd"`
|
||||
BitcoindMode *lncfg.Bitcoind `group:"bitcoind" namespace:"bitcoind"`
|
||||
|
@ -10,6 +10,6 @@ type Neutrino struct {
|
||||
MaxPeers int `long:"maxpeers" description:"Max number of inbound and outbound peers"`
|
||||
BanDuration time.Duration `long:"banduration" description:"How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second"`
|
||||
BanThreshold uint32 `long:"banthreshold" description:"Maximum allowed ban score before disconnecting and banning misbehaving peers."`
|
||||
FeeURL string `long:"feeurl" description:"Optional URL for fee estimation. If a URL is not specified, static fees will be used for estimation."`
|
||||
FeeURL string `long:"feeurl" description:"DEPRECATED: Optional URL for fee estimation. If a URL is not specified, static fees will be used for estimation."`
|
||||
AssertFilterHeader string `long:"assertfilterheader" description:"Optional filter header in height:hash format to assert the state of neutrino's filter header chain on startup. If the assertion does not hold, then the filter header chain will be re-synced from the genesis block."`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user