MCPcopy Create free account
hub / github.com/ElementsProject/elements / getblockheader

Function getblockheader

src/rpc/blockchain.cpp:949–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

947}
948
949static RPCHelpMan getblockheader()
950{
951 return RPCHelpMan{"getblockheader",
952 "\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
953 "If verbose is true, returns an Object with information about blockheader <hash>.\n",
954 {
955 {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
956 {"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for a json object, false for the hex-encoded data"},
957 },
958 {
959 RPCResult{"for verbose = true",
960 RPCResult::Type::OBJ, "", "",
961 {
962 {RPCResult::Type::STR_HEX, "hash", "the block hash (same as provided)"},
963 {RPCResult::Type::NUM, "confirmations", "The number of confirmations, or -1 if the block is not on the main chain"},
964 {RPCResult::Type::NUM, "height", "The block height or index"},
965 {RPCResult::Type::NUM, "version", "The block version"},
966 {RPCResult::Type::STR_HEX, "versionHex", "The block version formatted in hexadecimal"},
967 {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"},
968 {RPCResult::Type::NUM_TIME, "time", "The block time expressed in " + UNIX_EPOCH_TIME},
969 {RPCResult::Type::NUM_TIME, "mediantime", "The median block time expressed in " + UNIX_EPOCH_TIME},
970 {RPCResult::Type::NUM, "nonce", "The nonce"},
971 {RPCResult::Type::STR_HEX, "bits", "The bits"},
972 {RPCResult::Type::NUM, "difficulty", "The difficulty"},
973 {RPCResult::Type::STR_HEX, "chainwork", "Expected number of hashes required to produce the current chain"},
974 {RPCResult::Type::NUM, "nTx", "The number of transactions in the block"},
975 {RPCResult::Type::STR, "signblock_witness_asm", "ASM of sign block witness data"},
976 {RPCResult::Type::STR_HEX, "signblock_witness_hex", "Hex of sign block witness data"},
977 {RPCResult::Type::OBJ, "dynamic_parameters", "Dynamic federation parameters in the block, if any",
978 {
979 {RPCResult::Type::OBJ, "current", "enforced dynamic federation parameters. The signblockscript is published for each block, while others are published only at epoch start",
980 {
981 {RPCResult::Type::STR_HEX, "signblockscript", "signblock script"},
982 {RPCResult::Type::NUM, "max_block_witness", "Maximum serialized size of the block witness stack"},
983 {RPCResult::Type::STR_HEX, "fedpegscript", "fedpeg script"},
984 {RPCResult::Type::ARR, "extension_space", "array of hex-encoded strings",
985 {
986 {RPCResult::Type::ELISION, "", ""}
987 }}
988 }},
989 {RPCResult::Type::OBJ, "proposed", "Proposed parameters. Uninforced. Must be published in full",
990 {
991 {RPCResult::Type::ELISION, "", "same entries as current"}
992 }},
993 }},
994 {RPCResult::Type::STR_HEX, "previousblockhash", /*optional=*/true, "The hash of the previous block (if available)"},
995 {RPCResult::Type::STR_HEX, "nextblockhash", /*optional=*/true, "The hash of the next block (if available)"},
996 }},
997 RPCResult{"for verbose=false",
998 RPCResult::Type::STR_HEX, "", "A string that is serialized, hex-encoded data for block 'hash'"},
999 },
1000 RPCExamples{
1001 HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
1002 + HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
1003 },
1004 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1005{
1006 uint256 hash(ParseHashV(request.params[0], "hash"));

Callers

nothing calls this directly

Calls 11

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ParseHashVFunction · 0.85
JSONRPCErrorFunction · 0.85
blockheaderToJSONFunction · 0.85
get_boolMethod · 0.80
LookupBlockIndexMethod · 0.80
HexStrFunction · 0.50
isNullMethod · 0.45
TipMethod · 0.45
GetBlockHeaderMethod · 0.45

Tested by

no test coverage detected