How can I run bitcoind in pruning mode?

42

14

I read this comment:

You could consider running a pruning node, which is practically the same as a full node (including security), except it throws away some of the old history. Version 0.11 will make that possible

But I can't find details of how to run bitcoind in pruning mode. Questions on this site seem not to be recent enough to yield answers, and I also don't see a pruning mode in the bitcoind parameters.

Any insights into this?

Reinstate Monica

Posted 2015-05-21T09:02:08.400

Reputation: 913

as the comment said, this feature is not yet available in bitcoind.Luca Matteis 2015-05-21T09:28:20.560

1Ahhh I see, I didn't know 0.11 is a future version. Thanks for clarifying!Reinstate Monica 2015-05-21T09:57:39.440

Answers

30

By setting the -prune option.

-prune= Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. Warning: Reverting this setting requires re-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, 550 = automatically prune block files to stay under the specified target size in MiB)

The feature was originally introduced in Bitcoin Core 0.11 (see release notes).

As of version 0.12 pruning can be used while running a wallet. But note the -txindex and -rescan caveats.

Also note that the specified MiB will only include the block files and some undo space. Besides that you will also need some disk space for the chain state and block index databases.

Jannes

Posted 2015-05-21T09:02:08.400

Reputation: 5 823

1The argument to pruning is how much disk space to use for blocks and undo data associated with them. It does not include and does not apply to the chain state or block index databases. Do not increase the number to account for them.Pieter Wuille 2015-05-21T16:30:05.753

@PieterWuille That's why i decreased the number for him. In another question he mentioned he had 35GB diskspace. :) But thanks for the addition, you're right that my answer was a bit ambiguous.Jannes 2015-05-22T09:48:22.557

Well, if it disables the wallet funcionality, what would someone do with this node? Just mining? If so, in the event of successfully mining, what would be the destination of the generated bitcoin reward?Henrique Barcelos 2016-01-28T13:23:21.893

1@HenriqueBarcelos The upcoming version WILL allow running a wallet on a pruning node. The current version was just a stepping stone. As a side effect it made sure noone could possibly lose money due to a bug as there was no wallet at all. There are uses for (pruning) full nodes without wallet. For example you can use it as sort of a "firewall" between some internal application that you write yourself but that you don't want to directly hook up to the internet or possibly evil P2P traffic. Or to connect your Android wallet to it, so you are doing full validation, just not on the phone itself.Jannes 2016-01-28T17:28:16.827

20.12.0 enables wallet support, you might want to update this answer. :)Murch 2016-02-21T12:58:16.080

This answer needs to be updated. Pruning no longer disables wallet support and %u must be at least a minimum value according to the current parameter descriptionWilltech 2018-07-06T23:13:59.167

16

There are more details in the release notes.

To enable block pruning set prune=<N> on the command line or in bitcoin.conf, where N is the number of MiB to allot for raw block & undo data.

A value of 0 disables pruning. The minimal value above 0 is 550.

Where 550 is the size in MB you want the node to occupy in your system.

The bitcoin.conf is in the Bitcoin data directory, you can create a text file by the name there, if there isn't a bitcoin.conf yet.

Nate Eldredge

Posted 2015-05-21T09:02:08.400

Reputation: 21 420

bitcoin.conf doesnt exists ... – None – 2016-10-12T03:59:20.580

@user42169: "The configuration file is not automatically created; you can create it using your favorite plain-text editor. By default, Bitcoin (or bitcoind) will look for a file named bitcoin.conf in the bitcoin data directory, but both the data directory and the configuration file path may be changed using the -datadir and -conf command-line arguments." –Running Bitcoin: Bitcoin.conf Configuration File. First hit when I searched for "Bitcoin.conf doesn't exist". ;)

Murch 2016-10-12T07:35:17.223

where should the bitcoin.conf file reside on a win10 / win7 machine?Patoshi パトシ 2016-10-31T14:22:17.453

@duckx: I don't know. If you don't find the answer in documentation, please ask a new question.Nate Eldredge 2016-10-31T16:11:00.887

@duckx: Where is the configuration file of Bitcoin-Qt kept?.

Murch 2017-01-06T13:33:56.823

2

there was a followup on what a pruning node could actually be good for. Well, one answer would be shop systems who do not want/cannot rely on third party APIs like blockchain.info for their payment processing. a prune node would allow to be run on say a cheap vps with low space, while checking mempool for incoming transactions to implement payments. it would also allow checking/signing messages using the clients rpc calls, and to a limited degree it could allow checking the balances of addresses. I personally think(and I proposed intelligent pruning as I call it back in 2013) bitcoin devs implemented it wrongly. My implementation suggestion back then was to prune coins from the blockchain that had already been spent. Current behavior is to verify coins in transactions back to coinbase(aka when they were mined), while it should be sufficient to keep the last say 120 blocks plus every unspent transaction. Since the client verifies all blocks it gets, it could rely on those coins to be verified, yet it wouldnt need to know any previous transactions the coins went through.

John Deaux

Posted 2015-05-21T09:02:08.400

Reputation: 29

1No, that's exactly what Bitcoin Core does. All unspent coins are kept for further verification, and everything else is deleted (apart from the last day or so, to help with reorganisations).Pieter Wuille 2017-11-12T06:27:21.370