Is it possible to request an individual block from the bitcoin network, using the block height as parameter? Or would one have to start a node and wait until all blocks up to the desired height have been retrieved?

I'd like to be able to retrieve the actual, raw, serialized data, but e.g. blockchain.info, even when saying format=raw doesn't give you the raw block data.

N.B. If I understand bitcoin correctly though, I fear that if I don't build up a node by myself, starting from block 0, I can never be sure what I'm getting is true data from the bitcoin blockchain, no matter if I get it from blockchain.info (which could be compromised) or from a p2p peer, which is just one (potentially malicious) peer.

1 Answer 1


To request an individual block from a p2p peer, consider the get_data message, indicating what type of block (witness/compact/filtered).

Since you do not wish to do full block download and validation, you can first build a header chain to the most recent height, and then verify the block you are requesting is in the header chain. This would ensure that it would be expensive to falsify the block data you receive from a peer. You can also determine the block header hash corresponding to the height index you are interested in, as blocks cannot be uniquely referred to by height over the p2p network (two branches can have same height).

To build a header chain, consider the GET_HEADERS message, which also provides information (so-called block locator) about your current header branch so the peer can provide the headers for your node to catch-up to its header height.

  • @Eugene Did this answer your question?
    – James C.
    Commented Jan 27, 2019 at 14:21
  • Thanks James. Yes it did, and I hope this week I'll get around to actually confirming that, after which I intended to accept your answer. Commented Jan 28, 2019 at 21:57

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.