Dev Notes

Software Development Resources by David Egan.

Amend Bitcoin-Qt Persistent Settings for Bitcoin Core


Bitcoin, Cryptocurrency
David Egan

When you first run the Bitcoin core wallet, you will be given an opportunity to customise the location of the default data directory (which in Linux is $HOME/.bitcoin). If you need to change the data directory after the first launch, there is no option to do so from within the GUI. Many Stack Overflow answers suggest launching bitcoin-qt with the -datadir option - e.g. bitcoin-qt -datadir=/path/to/custom/datadir - this works, however you can easily amend the QT configuration so that the proper data directory is referenced by default.

QSettings for Bitcoin

The Bitcoin Core GUI wallet is based on QT, and it uses QSettings to store settings.

Users normally expect an application to remember its settings (window sizes and positions, options, etc.) across sessions. This information is often stored in the system registry on Windows, and in XML preferences files on Mac OS X. On Unix systems, in the absence of a standard, many applications (including the KDE applications) use INI text files. QSettings documentation

Location of Config File: Linux

On Linux/Unix systems, the following files are used by default:

  • $HOME/.config/Bitcoin/Bitcoin-Qt.conf
  • $HOME/.config/Bitcoin-Qt.conf

For myself, running Bitcoin Core under Ubuntu 16.04 the config file is $HOME/.config/Bitcoin/Bitcoin-Qt.conf

Location of Config File: Mac OS

On Mac OS X check the following locations:

  • $HOME/Library/Preferences/com.Bitcoin
  • $HOME/Library/Preferences/com.Bitcoin
  • /Library/Preferences/com.Bitcoin
  • /Library/Preferences/com.Bitcoin

Location of Config File: Windows

On Windows, check the following registry paths:

  • HKEY_CURRENT_USER\Software\Bitcoin
  • HKEY_CURRENT_USER\Software\Bitcoin
  • HKEY_LOCAL_MACHINE\Software\Bitcoin
  • HKEY_LOCAL_MACHINE\Software\Bitcoin

I don’t run MacOS or Windows so I haven’t checked these locations - this info is based on that provided in the QT QSettings documentation.

Edit the Config

Once you’ve located the config file, you can edit it like any other text file, and you’ll be able to amend the data directory:

# Make a backup just in case
cp $HOME/.config/Bitcoin/Bitcoin-Qt.conf $HOME/.config/Bitcoin/Bitcoin-Qt.conf.bak

# Edit the file
vim $HOME/.config/Bitcoin/Bitcoin-Qt.conf

# Save and exit

The data directory key is stdDataDir and looks like this:

[General]
...
strDataDir=/media/secure-hdd-2/bitcoin-data
...

Just amend this value to reference your data directory.

You can now launch bitcoin-qt as normal without specifying the custom data directory.

A Note on Moving Data Directories

Don’t open Bitcoin Core in a different data directory without first copying across all data from the original data directory (e.g. using rsync). Otherwise, blocks will need to be re-indexed - which is a lengthy process, and unecessary if you already have an up-to-date installation.

References


comments powered by Disqus