8

I'm using bitcoind on Ubuntu, headless. So there's no GUI to tell me when it's done.

So how do I know?

1

7 Answers 7

5

Run bitcoind getinfo in your shell of choice and compare the block count, listed after "blocks", to the block count listed here. If the two numbers are the same, your client is up to date.

5

Here's a script doing just that:

echo `bitcoin-cli getblockcount 2>&1`/`wget -O - https://blockchain.info/q/getblockcount 2>/dev/null`
3

Run bitcoind getblocktemplate. If you're not caught up, then it will come back with an error of -10.

4
  • I checked this, it's not so. (I checked it on the testnet network though, but should not be different that mainnet in this case.) Commented Apr 5, 2013 at 2:27
  • This is a slight hack, but it more or less works. Great :) Commented Apr 5, 2013 at 16:21
  • @StevenRoose, what was the problem you found with this method? When did it not work? It seems to be working for me, erroring when I'm in the middle of downloading blocks.
    – morsecoder
    Commented Nov 17, 2014 at 18:28
  • @StephenM347 it's been more than a year, probably there was an issue back then that has been resolved by now.. Commented Nov 17, 2014 at 20:52
1

The bitcoind command shows different errors now.

The new way to check is with bitcoin-cli getblocktemplate

Scripted use has been posted where I first ran accross this question

How to check if the block chain is up to date using bitcoind or json-rpc?

1

Simplest way is to run

bitcoind -blocknotify myscript.sh %s

On the blocks after bitcoind catches up with the blockchain, your scripts will get called with the new blockhash. You can print a message or do anything else required in this script

1

An alternative method, (working with recent versions), that does not depend on external websites, is to use bitcoin-cli getblockchaininfo and compare the headers field and the blocks field.

Currently, in order to sync the blockchain faster, headers are downloaded before the actual blocks. This is known as Headers-First Sync As a consequence, the number of block headers during the Initial Block Download (IBD) will be higher than the number of blocks. When this number "catches up" with the number of blocks, we can say we are "up to date" with the blockchain that our peers advertised to us.

I wrote a script to start bitcoind and outputs dots while still in IBD phase. When the blockchain is up to date, it will output a message. Here's the script: https://github.com/frz-dev/btcutils/blob/master/bitcoin-core/start-bitcoind.sh

0

With only a Web browser, you can visit http://bitcoinwatch.com/ to discover the current Bitcoin Network's block height or count.

Or point your bitcoin-cli to a production Bitcoind server and issue the following command (note, the *.conf file should be the one you use instead):

% ../bin/bitcoin-cli -conf=mainNet-productionServer.conf getblockcount

The easiest way is to query all of your peer connections for numerous details that also includes the "startingheight" for each of them.

% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getpeerinfo

Alternatively, the following libbitcoin-explorer command (bx, serves an analogous role as bitcoin-cli) provides only a single number when the bx client connects to a production bitcoin-server (previously called Obelisk) to query it for the Blockchain's height.

% bx fetch-height

To get the current height of your localServer that is being built try:

% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getblockcount

For contrasting purposes, the following bitcoin-cli help command provides additional details to for your local Blockchain image you are building:

% ../bin/bitcoin-cli -conf=mainNet.conf help gettxoutsetinfo gettxoutsetinfo

Returns statistics about the unspent transaction output set. Note this call may take some time.

Result: { "height":n, (numeric) The current block height (index) "bestblock": "hex", (string) the best block hash hex "transactions": n, (numeric) The number of transactions "txouts": n, (numeric) The number of output transactions "bytes_serialized": n, (numeric) The serialized size "hash_serialized": "hash", (string) The serialized hash "total_amount": x.xxx (numeric) The total amount }

Your blockchain is complete when the two numbers match. This approach will give you a good idea about your current status.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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