Skip to content

Add getblockheader RPC call #6247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2015

Conversation

petertodd
Copy link
Contributor

Alternative to getblock that works even when the block itself has been pruned, returning all available information. Right now the fact that you can't get this information in pruned mode makes pruned nodes quite a bit less useful for some applications.

Alternative to getblock that works even when the block itself has been
pruned, returning all available information.
@laanwj
Copy link
Member

laanwj commented Jun 7, 2015

Not against this, but you can get already get block headers using REST /rest/headers/<count>/<hash>.<ext>.

@jonasschnelli
Copy link
Contributor

Also not against this, but i think public blockchain data like blocks (headers), transactions or UTXO queries should go over REST instead over an authenticated RPC call. This would follow a more logical design.

Nevertheless, this can be useful because we never merge JSON support for REST Headers (https://github.com/bitcoin/bitcoin/pull/5486/files).

What about getting more in line with REST and also support requesting more than one header (/rest/headers/***<count>***/<hash>.<ext>.)?

@jgarzik
Copy link
Contributor

jgarzik commented Jun 7, 2015

That's the general goal of REST - querying public, unauthenticated blockchain data from the blockchain engine. Seems better placed there, than RPC.

@paveljanik
Copy link
Contributor

This allows you to get the needed information directly from the Debug window/Console without the needed hackery around the -rest cmdline etc. Very useful! Thanks Peter.

utACK

@@ -51,6 +51,32 @@ double GetDifficulty(const CBlockIndex* blockindex)
return dDiff;
}

UniValue blockheaderToJSON(const CBlockIndex* blockindex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a strong overlap with #5486 here - even the function is called the same. This does expose a few more values, also derived ones like confirmation and chainwork.

@laanwj
Copy link
Member

laanwj commented Jun 30, 2015

Tested ACK

@petertodd
Copy link
Contributor Author

@jgarzik Re: "unauthenticated" data, remember that this is trusted data in the sense that the client would be trusting the full node's opinion on what the valid chain is; I'm not sure I'd use the term "unauthenticated" in describing that, rather, public and trusted.

@laanwj laanwj merged commit 076badb into bitcoin:master Jul 2, 2015
laanwj added a commit that referenced this pull request Jul 2, 2015
076badb Add getblockheader RPC call (Peter Todd)
@dcousens
Copy link
Contributor

dcousens commented Dec 4, 2015

Needs to be updated in the docs?

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants