From 4394cc39af961a9b988d974df2351855ce385065 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 4 Jun 2020 13:10:20 +0200 Subject: [PATCH 1/3] lnd: expose user agent name as config option Expose the neutrino `UserAgentName` config option. This can be set by starting lnd with the `--neutrino.useragentname=` flag. --- chainregistry.go | 1 + docs/INSTALL.md | 1 + lncfg/neutrino.go | 1 + 3 files changed, 3 insertions(+) diff --git a/chainregistry.go b/chainregistry.go index 13f16e53..90b2a264 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -785,6 +785,7 @@ func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService, neutrino.MaxPeers = 8 neutrino.BanDuration = time.Hour * 48 + neutrino.UserAgentName = cfg.NeutrinoMode.UserAgentName neutrinoCS, err := neutrino.NewChainService(config) if err != nil { diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 2a24926c..bbef6626 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -197,6 +197,7 @@ neutrino: --neutrino.maxpeers= Max number of inbound and outbound peers --neutrino.banduration= How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second --neutrino.banthreshold= Maximum allowed ban score before disconnecting and banning misbehaving peers. + --neutrino.useragentname= Used to help identify ourselves to other bitcoin peers. ``` ## Bitcoind Options diff --git a/lncfg/neutrino.go b/lncfg/neutrino.go index b6f892bf..429600b4 100644 --- a/lncfg/neutrino.go +++ b/lncfg/neutrino.go @@ -12,4 +12,5 @@ type Neutrino struct { 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."` 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."` + UserAgentName string `long:"useragentname" description:"Used to help identify ourselves to other bitcoin peers"` } From bafab33beb7f3ce8a8d385cf8f140e095c306995 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 4 Jun 2020 13:12:08 +0200 Subject: [PATCH 2/3] lnd: expose user agent version as config option Expose the neutrino `UserAgentVersion` config option. This can be set by starting lnd with the `--neutrino.useragentversion=` flag. --- chainregistry.go | 1 + docs/INSTALL.md | 1 + lncfg/neutrino.go | 1 + 3 files changed, 3 insertions(+) diff --git a/chainregistry.go b/chainregistry.go index 90b2a264..772eee09 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -786,6 +786,7 @@ func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService, neutrino.MaxPeers = 8 neutrino.BanDuration = time.Hour * 48 neutrino.UserAgentName = cfg.NeutrinoMode.UserAgentName + neutrino.UserAgentVersion = cfg.NeutrinoMode.UserAgentVersion neutrinoCS, err := neutrino.NewChainService(config) if err != nil { diff --git a/docs/INSTALL.md b/docs/INSTALL.md index bbef6626..87e4360d 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -198,6 +198,7 @@ neutrino: --neutrino.banduration= How long to ban misbehaving peers. Valid time units are {s, m, h}. Minimum 1 second --neutrino.banthreshold= Maximum allowed ban score before disconnecting and banning misbehaving peers. --neutrino.useragentname= Used to help identify ourselves to other bitcoin peers. + --neutrino.useragentversion= Used to help identify ourselves to other bitcoin peers. ``` ## Bitcoind Options diff --git a/lncfg/neutrino.go b/lncfg/neutrino.go index 429600b4..4b638e6d 100644 --- a/lncfg/neutrino.go +++ b/lncfg/neutrino.go @@ -13,4 +13,5 @@ type Neutrino struct { FeeURL string `long:"feeurl" description:"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."` UserAgentName string `long:"useragentname" description:"Used to help identify ourselves to other bitcoin peers"` + UserAgentVersion string `long:"useragentversion" description:"Used to help identify ourselves to other bitcoin peers"` } From 51a5137d3f760ea0ed57b329322d3b488bd9d01d Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Fri, 18 Sep 2020 13:07:40 +0100 Subject: [PATCH 3/3] lnd: set default value for neutrino ua overrides --- config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config.go b/config.go index 11916a1a..a967941f 100644 --- a/config.go +++ b/config.go @@ -20,6 +20,7 @@ import ( "github.com/btcsuite/btcutil" flags "github.com/jessevdk/go-flags" + "github.com/lightninglabs/neutrino" "github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/chanbackup" @@ -313,6 +314,10 @@ func DefaultConfig() Config { RPCHost: defaultRPCHost, EstimateMode: defaultBitcoindEstimateMode, }, + NeutrinoMode: &lncfg.Neutrino{ + UserAgentName: neutrino.UserAgentName, + UserAgentVersion: neutrino.UserAgentVersion, + }, UnsafeDisconnect: true, MaxPendingChannels: lncfg.DefaultMaxPendingChannels, NoSeedBackup: defaultNoSeedBackup,