How to getheaders from blockchain?

1

1

I have run a full node on linux now I can run commands with bitcoin-cli like:

bitcoin-cli getbestblockhash

it returns:

0000000000344240308f54ded700542571b3df9efe05fab92e669099e20e0d92

or

bitcoin-cli getblockcount

82273

but I can't know where should I change get block to get headers:

https://bitcoin.org/en/developer-reference#getheaders

I want to get all headers instead of total blocks to have a SVP node.

Hamid Naghipour

Posted 2020-05-03T09:39:26.693

Reputation: 188

Answers

1

You can use the command bitcoin-cli getblockheader "hash" ( verbose ) to return a specific block header. For more info: bitcoin-cli help getblockheader

but I can't know where should I change get block to get headers: https://bitcoin.org/en/developer-reference#getheaders

I want to get all headers instead of total blocks to have a SVP node.

The getheaders message referenced in that link is part of the peer-to-peer gossip protocol between nodes, not the command line interface. From that link:

The getheaders message requests a headers message that provides block headers starting from a particular point in the block chain. It allows a peer which has been disconnected or started for the first time to get the headers it hasn’t seen yet.

chytrik

Posted 2020-05-03T09:39:26.693

Reputation: 13 841

Thank you, Yes I know about getblockheader command, but I want to have all headers instead of blocks. I have downloaded https://github.com/bitcoin/bitcoin and install it on linux. It works very well but I don't want to download 300GB, As I know SPV download only headers but I can't find any place to change type of message, change from block to header, something like a line to add bitcoin.conf

– Hamid Naghipour – 2020-05-03T13:41:45.433

1@HamidNaghipour Bitcoin-core is a full node; there is no configuration options to turn it into a light-verification (SPV) wallet. You can enable pruning mode to trim the datadirectroy size down (to just a few gigs if you so desire), but your machine will still download and validate the whole chain first. If you are looking for an SPV wallet specifically, bitcoin-core is not what you want. – chytrik – 2020-05-03T23:39:08.417