btcd
btcd copied to clipboard
GetBlockHeaderVerbose() doesn't return all data
❯ 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
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.