From 368743c9cbdbfc17126113feb62439010b5dae06 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 29 Mar 2021 10:23:26 +0200 Subject: [PATCH] lnd: turn off channel validation for Neutrino by default Downloading every block that contains a channel point takes a very long time when syncing the graph on mainnet with Neutrino. Therefore it makes sense to use routing.assumechanvalid=true since by using Neutrino a user already accepts the different trust model. Apparently the existence or meaning of the routing.assumechanvalid flag is unknown to a lot of users and is overlooked. This commit basically sets the default to routing.assumechanvalid=true for Neutrino. Because the CLI library doesn't support setting a bool value to false by the user if the default is true, we need to add an additional flag that is the inverse of the routing one, just for the case where a Neutrino user explicitly wants to turn on channel validation. --- lnd.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lnd.go b/lnd.go index e340a2fd..87d079e8 100644 --- a/lnd.go +++ b/lnd.go @@ -1569,6 +1569,17 @@ func initializeDatabases(ctx context.Context, func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService, func(), error) { + // Both channel validation flags are false by default but their meaning + // is the inverse of each other. Therefore both cannot be true. For + // every other case, the neutrino.validatechannels overwrites the + // routing.assumechanvalid value. + if cfg.NeutrinoMode.ValidateChannels && cfg.Routing.AssumeChannelValid { + return nil, nil, fmt.Errorf("can't set both " + + "neutrino.validatechannels and routing." + + "assumechanvalid to true at the same time") + } + cfg.Routing.AssumeChannelValid = !cfg.NeutrinoMode.ValidateChannels + // First we'll open the database file for neutrino, creating the // database if needed. We append the normalized network name here to // match the behavior of btcwallet.