From 1fa13e5cfc9a1fa00243c91bdcbbd9e2c8e082c9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 9 Sep 2018 17:34:10 -0700 Subject: [PATCH] chainregistry+config: enable neutrino fee estimation from external api Co-authored-by: Valentine Wallace --- chainregistry.go | 17 +++++++++++++++++ config.go | 1 + sample-lnd.conf | 3 +++ 3 files changed, 21 insertions(+) diff --git a/chainregistry.go b/chainregistry.go index b18733156..dea7cd8c3 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 eedcf8ff5..27e7f2efa 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 d49fc1cde..f4dce3ec7 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]