How to request a list of blocks using bitcoin-cli?

1

I'm trying to figure out how to use bitcoin-cli effectively to request a list of 50 blocks.

As far as I am aware, bitcoin-cli getblock list does not work. Also how to best extract information out of the getblock output.

will.i.am

Posted 2019-06-05T17:27:25.330

Reputation: 11

Answers

1

You cannot as there currently no way in Bitcoin Core's RPC to get multiple blocks with one command. You will have to issue multiple getblock commands. If you use a JSON-RPC client programmatically, you can use JSON-RPC's batched requests in order to have to only send one JSON-RPC request to execute multiple RPCs and get the results back in one response.

As for how to extract the information, you will need a JSON parser to extract the information. You can use verbosity level 2 in order to get the transactions decoded as well instead of just their txids.

Andrew Chow

Posted 2019-06-05T17:27:25.330

Reputation: 40 910