The weekly meeting on 2017-12-07 discussed allowing options to bitcoin to have some sensitivity to what network is in use. @theuni suggested having sections in the config file:
<cfields> an alternative to that would be sections in a config file. and on the
cmdline they'd look like namespaces. so, [testnet] port=5. or -testnet::port=5.
This approach is (more or less) supported by boost::program_options::detail::config_file_iterator
– when it sees a [testnet]
section with port=5
, it will treat that the same as “testnet.port=5”. So [testnet] port=5
(or testnet.port=5
without the section header) in bitcoin.conf and -testnet.port=5
on the command line.
The other aspect to this question is possibly limiting some options so that there is no possibility of accidental cross-contamination across networks. For example, if you’re using a particular wallet.dat on mainnet, you may not want to accidentally use the same wallet on testnet and risk reusing keys.
I’ve set this up so that the -addnode
and -wallet
options are NETWORK_ONLY
, so that if you have a bitcoin.conf:
wallet=/secret/wallet.dat
upnp=1
and you run bitcoind -testnet
or bitcoind -regtest
, then the wallet=
setting will be ignored, and should behave as if your bitcoin.conf had specified:
upnp=1
[main]
wallet=/secret/wallet.dat
For any NETWORK_ONLY
options, if you’re using -testnet
or -regtest
, you’ll have to add the prefix to any command line options. This was necessary for multiwallet.py
for instance.
I’ve left the “default” options as taking precedence over network specific ones, which might be backwards. So if you have:
maxmempool=200
[regtest]
maxmempool=100
your maxmempool will still be 200 on regtest. The advantage of doing it this way is that if you have [regtest] maxmempool=100
in bitcoin.conf, and then say bitcoind -regtest -maxmempool=200
, the same result is probably in line with what you expect…
The other thing to note is that I’m using the chain names from chainparamsbase.cpp
/ ChainNameFromCommandLine
, so the sections are [main]
, [test]
and [regtest]
; not [mainnet]
or [testnet]
as might be expected.
Thoughts? Ping @MeshCollider @laanwj @jonasschnelli @morcos