Skip to content

Commit

Permalink
chainregistry+config: enable neutrino fee estimation from external api
Browse files Browse the repository at this point in the history
Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
  • Loading branch information
Roasbeef and valentinewallace committed Apr 11, 2019
1 parent cf63146 commit 9d3a912
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions chainregistry.go
Expand Up @@ -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,
)
Expand Down
1 change: 1 addition & 0 deletions config.go
Expand Up @@ -129,6 +129,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:"Use this URL to for fee estimation."`
}

type btcdConfig struct {
Expand Down
3 changes: 3 additions & 0 deletions sample-lnd.conf
Expand Up @@ -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]

Expand Down

0 comments on commit 9d3a912

Please sign in to comment.