diff --git a/chainregistry.go b/chainregistry.go index b1873315..dea7cd8c 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -208,6 +208,23 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB, return nil, err } + // If the user provided an API for fee estimation, activate it now. + if cfg.NeutrinoMode.FeeURL != "" { + ltndLog.Infof("Using API fee estimator!") + + estimator := lnwallet.NewWebAPIFeeEstimator( + lnwallet.SparseConfFeeSource{ + URL: cfg.NeutrinoMode.FeeURL, + }, + defaultBitcoinStaticFeePerKW, + ) + + if err := estimator.Start(); err != nil { + return nil, err + } + cc.feeEstimator = estimator + } + walletConfig.ChainSource = chain.NewNeutrinoClient( activeNetParams.Params, neutrinoCS, ) diff --git a/config.go b/config.go index eedcf8ff..27e7f2ef 100644 --- a/config.go +++ b/config.go @@ -130,6 +130,7 @@ type neutrinoConfig 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."` } type btcdConfig struct { diff --git a/sample-lnd.conf b/sample-lnd.conf index d49fc1cd..f4dce3ec 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -233,6 +233,9 @@ bitcoin.node=btcd ; Add a peer to connect with at startup. ; neutrino.addpeer= +; Set a URL source for fee estimates. +; neutrino.feeurl= + [Litecoin]