Skip to content
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

GetBlockHeaderVerbose() doesn't return all data #2311

Open
caevv opened this issue Jan 31, 2025 · 1 comment
Open

GetBlockHeaderVerbose() doesn't return all data #2311

caevv opened this issue Jan 31, 2025 · 1 comment

Comments

@caevv
Copy link

caevv commented Jan 31, 2025

❯ bitcoin-cli getblockheader 6822fb896a908ba51e574716fd8f2511087d39659659696af459bddb399cec40

{
  "hash": "6822fb896a908ba51e574716fd8f2511087d39659659696af459bddb399cec40",
  "confirmations": 1,
  "height": 203,
  "version": 805306368,
  "versionHex": "30000000",
  "merkleroot": "3ad5be02d14d471391e156390f4d00999c7832a6adde6ad438baa38bd15b2049",
  "time": 1737050538,
  "mediantime": 1737049291,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000198",
  "nTx": 8,
  "previousblockhash": "79121b6dee87ae7ee8b0d2a687d64841e0b6cf304f6b3ebd627d9927e993e487"
}

But the response of GetBlockHeaderVerbose() is:

type GetBlockHeaderVerboseResult struct {
	Hash          string  `json:"hash"`
	Confirmations int64   `json:"confirmations"`
	Height        int32   `json:"height"`
	Version       int32   `json:"version"`
	VersionHex    string  `json:"versionHex"`
	MerkleRoot    string  `json:"merkleroot"`
	Time          int64   `json:"time"`
	Nonce         uint64  `json:"nonce"`
	Bits          string  `json:"bits"`
	Difficulty    float64 `json:"difficulty"`
	PreviousHash  string  `json:"previousblockhash,omitempty"`
	NextHash      string  `json:"nextblockhash,omitempty"`
}

It's missing Chainwork, nTx and MedianTime

@Roasbeef
Copy link
Member

Roasbeef commented Feb 7, 2025

If you need those fields, you can either make a wrapper struct that embeds the existing GetBlockHeaderVerboseResult which adds those new fields. Or you can make a PR adding them. If you just wrap the struct, then you can use the raw message requests to make the RPC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants