Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: DrakonX on November 25, 2017, 04:46:44 PM



Title: How to detect (with bitcoin-cli) if the blockchain download has been completed
Post by: DrakonX on November 25, 2017, 04:46:44 PM
When running Bitcoin Core on Windows, I have a GUI that tells me when the blockchain has been completely downloaded. But how do I check that with bitcoin-cli on the command line of linux?


Title: Re: How to detect (with bitcoin-cli) if the blockchain download has been completed
Post by: onnz423 on November 25, 2017, 06:10:39 PM
You'll have to have the bitcoind running as a daemon on the background, as well as rpc user and password set for it. From bitcoin-cli if there are rpc details, you can check the amount of blocks synced by this command: bitcoin-cli getblockcount or ./bitcoin-cli getblockcount if running from the same directory. Is this the answer that you were looking for?


Title: Re: How to detect (with bitcoin-cli) if the blockchain download has been completed
Post by: DrakonX on November 25, 2017, 11:42:46 PM
Thanks for your reply. I'm not sure. I mean, there must be a way to check if the blockchain loading is complete without checking how many blocks do currently exist first and then compare this number with the number of loaded block.

I have something in minde like "bitcoin-cli -proof-completeness" and getting "yes" or "no" as a result. I just want to know when the system is ready to spend any funds.


Title: Re: How to detect (with bitcoin-cli) if the blockchain download has been completed
Post by: achow101 on November 26, 2017, 12:47:01 AM
Thanks for your reply. I'm not sure. I mean, there must be a way to check if the blockchain loading is complete without checking how many blocks do currently exist first and then compare this number with the number of loaded block.

I have something in minde like "bitcoin-cli -proof-completeness" and getting "yes" or "no" as a result. I just want to know when the system is ready to spend any funds.
This is not possible. Bitcoind does not and cannot know when the blockchain is actually fully synced until it is fully synced (and even then it technically doesn't know it is synced). The best you can do is check the blockchain height.

There is a variable called IsInitialBlockDownload and in the next major release of Bitcoin Core, that variable will be included in the getblockchaininfo output. That is what tells the GUI to show whether it is in syncing mode or not, but IBD can be set to false before it is actually fully synced.