1

My main bitcoin.conf is located in the AppData. Setting the datadir in it or via argument allows me to let the daemon/qt load another bitcoin.conf that is located in the DataDir. I can also change the main bitcoin.conf by setting the conf via argument and I can also specify includeconf in the config to load another config file.

I'd like to know how the priority will be when using all of the above features on conflicting keys as well as if merging is done and if so, how.

For instance: Which of the values will be used if I define its key in the main config as well as in the config at the datadir and even in a config that was included using includeconf? Is it also possible to use includeconf twice or more times to load more than one additional configuration?

What if I use includeconf in the config of the datadir and in the main conf and both files also contain conflicting keys? Will there be any merging at all?

Martin Braun
  • 127
  • 5

1 Answers1

2

Firstly, command line arguments always override the config files.

Secondly, if you specify a config file using -conf, the default config file in the datadir will not be used - only the config file you specified will be used.

Thirdly, if you don't specify a -datadir as a command line argument, the bitcoin.conf in the default datadir location will be loaded. If that config file specifies a different datadir be used, that chosen datadir will be used for blocks, wallets, etc. but no config file will be loaded from it. The config file in the chosen datadir will only be used if you load Bitcoin with the -datadir arg set on the command line so that it looks in that datadir first.

Generally, if there is a conflict between two options, the first one will win. That means an option set in the main conf file will take precedence over one set in an includeconf file. You can use multiple includeconf augments in the main config file but they can't be recursive - you can't use includeconf inside a file that was included using includeconf.

The exception to this is that options declared network-specific (e.g. [main]) will take precedence over non-network-specific options, even if declared later.

Source

meshcollider
  • 11,815
  • 4
  • 25
  • 53
  • Thank you. Regarding the conflict of keys: If a key is behind the datadir key as well as in the config file of the datadir directory, the key in the main config file will still be the first, right? So the order of priority is main config, datadir config (if -conf wasn't used), includeconf config, ..., right? Also can I use includeconf in the config file at datadir as well? – Martin Braun Dec 19 '21 at 13:50
  • I've updated my answer to answer your followups. – meshcollider Dec 19 '21 at 20:40