I'm interested in running a private test network to experiment with various chain parameters. These are hardcoded in chainparams.cpp.


Unfortunately, this means that to run any experiments, I need to recompile Bitcoin Core.

What I'd like to do instead is simply edit a configuration file, then restart Bitcoin Core.

Why are chain parameters hard coded this way? Is there any way to inject my own chain parameters through a configuration file without recompiling Bitcoin Core?

  • You would have to empty your datadir before restarting, as the chain stored might not be compatible with the new values set in the config file. Also, this might be a useful feature for testing, but making configurable parameters like this would likely confuse most users. – morsecoder Feb 1 '15 at 4:24

I don't think there's really any better reason than "Satoshi Nakamoto chose to write the code that way, and nobody ever changed it".

There's no inherent reason why these values couldn't be loaded from a configuration file, but there's a general principle that config files are intended for parameters that are user configurable. A Bitcoin user couldn't change anything in that config file or their client would quit working with the rest of the network. Developers might want to, but they are expected to be comfortable with recompiling. So presumably nobody thought it was worthwhile to write the code to parse a config file for these values.

So if you want to be able to modify those values by editing a config file, you'll first have to write the code to parse and load the config file. Which, of course, also involves recompiling (and a lot more work besides). Perhaps now you can see why nobody has wanted to do it so far. But if you do, you can offer the code back to the main Bitcoin Core development line, and maybe it will be incorporated, thus saving someone in the future from this quandary.

Recompiling Bitcoin Core is not all that much work, once you have a development environment and necessary dependencies installed. And when you have compiled it once, changes to the chain parameters should only require you to recompile one file and relink (which Make will do automatically).

| improve this answer | |

The glib answer would be, "Because then users would come on the forums and complain that changing nTargetSpacing causes their client to stop syncronizing."

The other issue is that a lot of the really interesting parameters aren't in chainparams at all. For example, the function that determines block rewards is in main.cpp.

But I don't think there's a technical issue preventing you from making those things config options.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.