DEV Community

Aike de Jongste
Aike de Jongste

Posted on • Originally published at runrails.com on

Shrink your Bitcoin blockchain with pruning

Even though the current bitcoin prices are currently very low I still think it's an interesting technology. Especially the Lightning protocol. And I'm looking for a way to somehow use it in surface interval, a project that I'm working on. But currently the blockchain is almost 200GB and that's a bit much for my server.

If you don’t want to have the whole bitcoin blockchain on your computer or server you don’t have to. There is an option that deletes previously verified blocks from your local copy. This is called pruning. To enable it you have to add the following line to your bitcoind config. This config file is usually in ‘/etc/bitcoin/bitcoin.conf’.

prune=5000

After that you have to restart bitcoind and 5 minutes later you have a whole lot more free diskspace.

You can check if pruning is enabled with:

bitcoin-cli getblockchaininfo | grep prune

It will output something like this:

"pruned": true, 
"pruneheight": 552518, 
"prune_target_size": 1073741824,

Good to know:

The prune= value has to be higher than 550. And the number indicates the diskspace to be used in Megabytes. I went with 5000 because 5GB seemed reasonable to me.

Troubleshooting:

After I enabled the prune=5000 option bitcoind wouldn’t start anymore. There was no usable error:

root@cryptodoos:~# service bitcoind start
Job for bitcoind.service failed because the control process exited with error code.
See "systemctl status bitcoind.service" and "journalctl -xe" for details.

I checked for typo’s in the config file and read the logfile in /var/lib/bitcoin/debug.log but everything seemed fine. So I started the daemon by hand. This is usually a good approach to see what’s going on.

root@cryptodoos:~# /usr/bin/bitcoind -daemon -datadir=/var/lib/bitcoin \
-conf=/etc/bitcoin/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid

Error: Prune mode is incompatible with -txindex.

And there it is. You have to disable txindex in the bitcoin.conf to use pruning.

The post How to enable pruning on bitcoind appeared first on RunRails.

Discussion (3)

Collapse
siffon404 profile image
siffon404

If you're willing to earn money by trading cryptocurrency, the first thing you need to do is to find the best auto-trading application. I know that it might sound simple at first, but there are way too many scams on the internet. Through trial and error, I've found Quantum Code echte site. But you will find more online if you look properly.

Collapse
cermitio profile image
Cermitio

Thank you for the info. I just recently started to understand this topic. Now I'm even trying to engage in trading. I got acquainted with the top forex brokers list and chose a broker based on reviews and reviews. I'm still satisfied with everything, the interface is very convenient, the withdrawal of money to a credit card is fast.

Collapse
himann524 profile image
Himann524

That's an interesting article, but I'd like to find out more about the actual trading and earning money.