-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Docs: Create default bitcoin.conf file on startup #13761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
04be012
to
a517c47
Compare
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add the filenameto src/Makefile.am
Line 92 in 29b4ee6
BITCOIN_CORE_H = \ |
src/bitcoin.conf
Outdated
@@ -0,0 +1,147 @@ | |||
R"(## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's The R and ( for?
src/bitcoin.conf
Outdated
#min=1 | ||
|
||
# Minimize to the system tray | ||
#minimizetotray=1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the ) for ?
src/bitcoind.cpp
Outdated
// default bitcoin.conf file template | ||
const char* g_default_conf_file = | ||
#include <bitcoin.conf> | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good way to do this. I'd prefer rename to bitcoin_conf.h
and move const char ...
into that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The R() is for being able to #include
the file. But I like your idea better. I will update. Thanks for the suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also sorry for not explaining further. R() is for multiline string literal: https://stackoverflow.com/a/20508617/2302781
1f46306
to
6249702
Compare
fb4194d
to
f2df814
Compare
Fixes bitcoin#10746. If no -conf flag is passed and no bitcoin.conf file exists in the datadir, then a bitcoin.conf template will be created in the datadir. This conf file will have no configurations set, only explanatory comments. The default bitcoin.conf template was copied from contrib/debian/examples/bitcoin.conf.
35ae6b3
to
08def4b
Compare
@ken2812221 updated! |
I'm conceptually unsure if the daemon binary should take care of the configuration management (if even supporting a template make sense). This seems to be better address on the package manager level. |
I can understand that point of view, however I think that many users are accustomed to config files being generated automatically for them from a binary. When people see that the On a higher level, I'm hoping to start contributing more to Bitcoin Core and I'd like to start with some changes that improve usability for new users. It can be quite intimidating for people. |
If |
I've updated the PR to create the template config file immediately after creation of the datadir. |
I tend to agree. Daemons should not write their own configuration file. |
What about a compromise: always create a |
I like this. I also think we should disable the startup logging message saying a conf file is being used, unless it is actually true. If there is no conf file, then we can print a message instructing the user how/where to create one. What do you think? |
I've updated things so that a |
src/conf_file.h
Outdated
## Quick Primer on addnode vs connect ## | ||
## Let's say for instance you use addnode=4.2.2.4 ## | ||
## addnode will connect you to and tell you about the ## | ||
## nodes connected to 4.2.2.4. In addition it will tell ## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please left-indent this entire block and increase the total line length to say 78 chars. That will make it easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@practicalswift I copied this from contrib/debian/examples/bitcoin.conf
. I'm happy to reformat the file and make these changes, but do you think they should be made in both places?
src/conf_file.h
Outdated
## all of them to open lots of connections. Instead ## | ||
## 'connect' them all to one node that is port forwarded ## | ||
## and has lots of connections. ## | ||
## Thanks goes to [Noodle] on Freenode. ## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the greeting :-)
src/conf_file.h
Outdated
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC api. The first | ||
# method(DEPRECATED) is to set this pair for the server and client: | ||
#rpcuser=Ulysseys | ||
#rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the 385593
part could be longer and randomized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
part could be longer and randomized?
What do you mean by this? This is an example password that we'd never want anyone to use, and actually comes from the sample bitcoin.conf on the wiki.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fanquake Yes I know but randomizing would make it slighly less painful for newcomers to make the mistake of uncommenting as-is. Perhaps that is overkill though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's overkill. If anything we should remove the term 'Number' from the example pw so people don't think it must be limited to a numeric value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense!
Afaik you can't download that binary separately from the "official" source, and the release signatures don't cover individual files either: https://bitcoincore.org/en/download/ |
They are hosted here: https://bitcoincore.org/bin/bitcoin-core-0.16.2/ And when installing the bitcoind package on ubuntu: |
It's also not possible. When you do a system wide installation of |
@leishman these are packages with multiple files, which you can add files to by tweaking the deploy scripts. Similarly, it should be possible for the ubuntu install script to put this template file somewhere, since it also manages put the icon in /usr/share. |
@sipa so do you think the approach I have taken in this PR is reasonable? |
To clarify my position: I prefer a more elegant solution, but I'm OK with doing that later. I do however recommend adding a functional test to check if this file is indeed created. |
@Sjors ok I'll add in that test |
@Sjors After digging into the testing framework it looks like testing for this behavior is actually quite tricky. The current functionality only creates a |
@jnewbery is there already a test which checks that the |
I don't think so. See
|
Yeah, currently the test framework always puts the Testing default datadir creation could be a testing feature we add in a later PR. |
Pulling out logging update into a separate PR: #14057 |
What do you think about changing the conditional here: https://github.com/bitcoin/bitcoin/pull/13761/files#diff-b7702a084eb00fb47f9800fd68271951R791 to check whether the directory is empty instead of whether the directory exists (ie create the wallets subdirectory and example conf file when a non-existent or empty datadir is used). That makes more sense to me, and would be testable in the existing test framework. |
Needs rebase |
There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened. |
…tcoin.conf" message on startup if conf file exists 946107a Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. (Alexander Leishman) Pull request description: Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exist. This PR changes the logic to: **If config file does not exist and no -conf flag passed, log:** `Config file: FILE_PATH (not found, skipping)`. Where `FILE_PATH` is the default or the path passed in with the `-conf` flag. **If config file does not exist and -conf flag passed with incorrect path, log warning:** `Warning: The specified config file FILE_PATH does not exist` **If config file exists, log**: `Config file: FILE_PATH` Note: This is a (modified) subset of changes introduced in bitcoin#13761 which creates a default example config file. I think it makes sense to extract this small bit out into a separate PR. Tree-SHA512: be0f0ae6a0c9041e2d6acb54d2563bbcc79786fb2f8bf9a963fe01bc54cd4e388b89079fde1eb79f7f17099776428e5e984bf7107590a3d1ecfc0562dbc6e3f5
…tcoin.conf" message on startup if conf file exists 946107a Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. (Alexander Leishman) Pull request description: Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exist. This PR changes the logic to: **If config file does not exist and no -conf flag passed, log:** `Config file: FILE_PATH (not found, skipping)`. Where `FILE_PATH` is the default or the path passed in with the `-conf` flag. **If config file does not exist and -conf flag passed with incorrect path, log warning:** `Warning: The specified config file FILE_PATH does not exist` **If config file exists, log**: `Config file: FILE_PATH` Note: This is a (modified) subset of changes introduced in bitcoin#13761 which creates a default example config file. I think it makes sense to extract this small bit out into a separate PR. Tree-SHA512: be0f0ae6a0c9041e2d6acb54d2563bbcc79786fb2f8bf9a963fe01bc54cd4e388b89079fde1eb79f7f17099776428e5e984bf7107590a3d1ecfc0562dbc6e3f5
…tcoin.conf" message on startup if conf file exists 946107a Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. (Alexander Leishman) Pull request description: Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exist. This PR changes the logic to: **If config file does not exist and no -conf flag passed, log:** `Config file: FILE_PATH (not found, skipping)`. Where `FILE_PATH` is the default or the path passed in with the `-conf` flag. **If config file does not exist and -conf flag passed with incorrect path, log warning:** `Warning: The specified config file FILE_PATH does not exist` **If config file exists, log**: `Config file: FILE_PATH` Note: This is a (modified) subset of changes introduced in bitcoin#13761 which creates a default example config file. I think it makes sense to extract this small bit out into a separate PR. Tree-SHA512: be0f0ae6a0c9041e2d6acb54d2563bbcc79786fb2f8bf9a963fe01bc54cd4e388b89079fde1eb79f7f17099776428e5e984bf7107590a3d1ecfc0562dbc6e3f5
…tcoin.conf" message on startup if conf file exists 946107a Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. (Alexander Leishman) Pull request description: Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exist. This PR changes the logic to: **If config file does not exist and no -conf flag passed, log:** `Config file: FILE_PATH (not found, skipping)`. Where `FILE_PATH` is the default or the path passed in with the `-conf` flag. **If config file does not exist and -conf flag passed with incorrect path, log warning:** `Warning: The specified config file FILE_PATH does not exist` **If config file exists, log**: `Config file: FILE_PATH` Note: This is a (modified) subset of changes introduced in bitcoin#13761 which creates a default example config file. I think it makes sense to extract this small bit out into a separate PR. Tree-SHA512: be0f0ae6a0c9041e2d6acb54d2563bbcc79786fb2f8bf9a963fe01bc54cd4e388b89079fde1eb79f7f17099776428e5e984bf7107590a3d1ecfc0562dbc6e3f5
…tcoin.conf" message on startup if conf file exists 946107a Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists. (Alexander Leishman) Pull request description: Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exist. This PR changes the logic to: **If config file does not exist and no -conf flag passed, log:** `Config file: FILE_PATH (not found, skipping)`. Where `FILE_PATH` is the default or the path passed in with the `-conf` flag. **If config file does not exist and -conf flag passed with incorrect path, log warning:** `Warning: The specified config file FILE_PATH does not exist` **If config file exists, log**: `Config file: FILE_PATH` Note: This is a (modified) subset of changes introduced in bitcoin#13761 which creates a default example config file. I think it makes sense to extract this small bit out into a separate PR. Tree-SHA512: be0f0ae6a0c9041e2d6acb54d2563bbcc79786fb2f8bf9a963fe01bc54cd4e388b89079fde1eb79f7f17099776428e5e984bf7107590a3d1ecfc0562dbc6e3f5
Fixes #10746. If no -conf flag is passed and no bitcoin.conf file exists in the datadir, then a bitcoin.conf template will be created in the datadir. This conf file will have no configurations set, only explanatory comments. The default bitcoin.conf template was copied from contrib/debian/examples/bitcoin.conf.
The lack of a default config file historically causes a lot of confusion for new users because bitcoind will print
Using config file $DATADIR/bitcoin.conf
on startup even if no file exists.Curious if error handling is being done properly here or if file permissions need to be considered. I don't think a failure to create this file should terminate the process.