Title: Determining "Up-To-Date-Ness" via RPC commands Post by: l008com II on July 02, 2020, 01:55:15 PM After doing some reading on the topic, it looks like the only way to determine if a wallet is up to date, and this is apparently what the wallets do, is just see how old the newest block is. With bitcoin, if the newest block is less than 90 minutes old, you are considered up to date.
I'm trying to recreate this in my own web dashboard using RPC commands. So I do the following.... First I run this Code: getblockcount Then I run this Code: getblockhash {number from previous step} Then I run this to look up all the info on this block and ultimately get it's ['time'] attribute: Code: getblock {hash from previous step} But this is where things go awry. This returns an error: Code: {code} => -32700 This is inside a php shell script using the built in curl module. I also tried running this command using `curl` directly from the command line. Code: curl --user *username* --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["08eea4f5d6dfac07937095695aea67ba1548c64b64bae99b2f4f20a34e08aea0"] }' -H 'content-type: text/plain;' http://*lanIP*:*port#*/ Any thoughts? Is the `getblock` command broken? Or is there something I'm doing wrong in my code? Title: Re: Determining "Up-To-Date-Ness" via RPC commands Post by: achow101 on July 02, 2020, 02:35:06 PM We would have to see your code. You are probably missing something in the JSON object constructions.
There's an easier way to check this. Bitcoin Core has an internal check called IsInitialBlockDownload. The boolean result of this is output in getblockchaininfo as the initialblockdownload field. When that becomes false, you can be reasonably sure that the node is fully synced. So you can just poll the getblockchaininfo RPC and wait for initialblockdownload to become false. Title: Re: Determining "Up-To-Date-Ness" via RPC commands Post by: TheArchaeologist on July 03, 2020, 03:43:52 PM I'm doing the exact same thing as you describe for my custom parser. This is in python:
Code: <snip> Title: Re: Determining "Up-To-Date-Ness" via RPC commands Post by: l008com II on July 06, 2020, 12:29:25 PM We would have to see your code. You are probably missing something in the JSON object constructions. There's an easier way to check this. Bitcoin Core has an internal check called IsInitialBlockDownload. The boolean result of this is output in getblockchaininfo as the initialblockdownload field. When that becomes false, you can be reasonably sure that the node is fully synced. So you can just poll the getblockchaininfo RPC and wait for initialblockdownload to become false. I would much rather do it that simpler way. However when I run `getblockchaininfo`, the key 'initialblockdownload' is always blank. All the other keys have values but that one does not Code: [chain] => main Title: Re: Determining "Up-To-Date-Ness" via RPC commands Post by: achow101 on July 06, 2020, 03:20:14 PM I would much rather do it that simpler way. However when I run `getblockchaininfo`, the key 'initialblockdownload' is always blank. All the other keys have values but that one does not The JSON-RPC interface won't return a blank value for something in a JSON object, that's not allowed. It's probably returning false and your software is interpreting that to be blank or null.Code: [chain] => main |