You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chain/json/header exposes the wire (native) and electrumx_tag serializers but not a bitcoind_tag variant. The block serializer (src/chain/json/block.cpp) already carries the
full bitcoind family (bitcoind_tag / bitcoind_hashed_tag / bitcoind_verbose_tag / bitcoind_embedded_tag) and inlines the header fields into the block's bitcoind encoding, but
there is no standalone bitcoind header serializer. Consumers that need a Core-format header JSON
must hand-roll it.
Proposed
Mirror the existing electrum header serializer (#1822):
Fields mirror the header portion of DEFINE_JSON_FROM_TAGGED(bitcoind_tag, block): hash, version, versionHex, merkleroot, time, nonce, bits, difficulty.
Chain-context properties (confirmations, height, mediantime, previousblockhash, nextblockhash) stay a consumer responsibility, consistent with the block bitcoind serializer
(which documents them as chain, not block, properties).
src/chain/json/block.cppDEFINE_JSON_FROM_TAGGED(bitcoind_tag, block) is the reference for field formatting (versionHex / bits as big-endian base16, difficulty as the computed double).
Consumer
libbitcoin/libbitcoin-server#795 hand-rolls this as header_to_bitcoind in protocol_bitcoind_rpc_json.cpp. Once this lands it collapses to value_from(bitcoind(*header))
in both getblockheader and the REST /rest/headers handler, and the protocol-layer helper is
removed. Raised from review feedback on that PR.
Testing
Exact-string assertion via json::value_from(bitcoind(instance)), as in #1822. Reusing the
block bitcoind test instance (header{ 42, null_hash, one_hash, 43, 44, 45 }) yields "versionHex":"0000002a", "bits":"0000002c", "difficulty":1.0279680609929991E73.
Summary
chain/json/headerexposes the wire (native) andelectrumx_tagserializers but not abitcoind_tagvariant. The block serializer (src/chain/json/block.cpp) already carries thefull bitcoind family (
bitcoind_tag/bitcoind_hashed_tag/bitcoind_verbose_tag/bitcoind_embedded_tag) and inlines the header fields into the block's bitcoind encoding, butthere is no standalone bitcoind header serializer. Consumers that need a Core-format header JSON
must hand-roll it.
Proposed
Mirror the existing electrum header serializer (#1822):
include/bitcoin/system/chain/json/header.hpp: addDECLARE_JSON_TAGGED_INVOKE(bitcoind_tag, header).src/chain/json/header.cpp: addDEFINE_JSON_FROM_TAGGED(bitcoind_tag, header).test/chain/json/header.cpp: addheader__json__bitcoind__expected.Fields mirror the header portion of
DEFINE_JSON_FROM_TAGGED(bitcoind_tag, block):hash,version,versionHex,merkleroot,time,nonce,bits,difficulty.Chain-context properties (
confirmations,height,mediantime,previousblockhash,nextblockhash) stay a consumer responsibility, consistent with the block bitcoind serializer(which documents them as chain, not block, properties).
Precedent
DEFINE_JSON_FROM_TAGGED(electrumx_tag, header). This is the exact analog forbitcoind_tag.src/chain/json/block.cppDEFINE_JSON_FROM_TAGGED(bitcoind_tag, block)is the reference for field formatting (versionHex/bitsas big-endian base16,difficultyas the computed double).Consumer
libbitcoin/libbitcoin-server#795 hand-rolls this as
header_to_bitcoindinprotocol_bitcoind_rpc_json.cpp. Once this lands it collapses tovalue_from(bitcoind(*header))in both
getblockheaderand the REST/rest/headershandler, and the protocol-layer helper isremoved. Raised from review feedback on that PR.
Testing
Exact-string assertion via
json::value_from(bitcoind(instance)), as in #1822. Reusing theblock bitcoind test instance (
header{ 42, null_hash, one_hash, 43, 44, 45 }) yields"versionHex":"0000002a","bits":"0000002c","difficulty":1.0279680609929991E73.