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

<p>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).</p>

<p>To build a header chain, consider the <code>GET_HEADERS</code> 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.</p>

CC BY-SA 4.0
2019-01-27T14:21:31.387Z
@Eugene Did this answer your question?
James C.
CC BY-SA 4.0
2019-01-28T21:57:52.597Z
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.
Evgeniy Berezovsky
CC BY-SA 4.0
2019-01-25T13:23:18.320Z
2019-01-25T13:23:18.320Z
James C.
<p>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?</p>

<p>I'd like to be able to retrieve the actual, raw, serialized data, but e.g. <a href="https://blockchain.info/block-height/50000?format=json" rel="nofollow noreferrer">blockchain.info</a>, even when saying <code>format=raw</code> doesn't give you the raw block data.</p>

<p>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.</p>

<blockchain><blockchain.info><block>
Getting individual block by height from Bitcoin P2P network
Evgeniy Berezovsky
# Getting individual block by height from Bitcoin P2P network

(Asked by: username_0 on 2019-01-25)

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](https://blockchain.info/block-height/50000?format=json), 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.

**Tags:** blockchain, blockchain.info, block


---

## 1 answers

### Answer by username_1 on 2019-01-25. Score: 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.

> **Comments:**
> **username_1**: @Eugene Did this answer your question?  
> **username_0**: Thanks username_1. Yes it did, and I hope this week I'll get around to actually confirming that, after which I intended to accept your answer.  

---

