blockchain.block.header returns wrong response format when cp_height = 0
Summary
blockchain.block.header wraps its result in a JSON object instead of returning a plain hex string when cp_height is zero. This breaks Electrum wallet clients (confirmed with Sparrow) that expect the response format specified in the Electrum protocol.
Observed behavior
{"jsonrpc":"2.0","id":37,"result":{"hex":"0000092090a327..."}}
Expected behavior
{"jsonrpc":"2.0","id":37,"result":"0000092090a327..."}
Protocol spec
Per the Electrum protocol spec:
cp_height = 0 → result is a plain hex string
cp_height > 0 → result is a dict with header, branch, and root keys
Root cause
blockchain_block_headers() in src/protocols/electrum/protocol_electrum_headers.cpp is the shared implementation for both blockchain.block.header and blockchain.block.headers. It unconditionally builds a value_t{ object_t{} } for all code paths, including the single-header no-proof case that must return a plain string.
A second related bug exists in the same function: the pre-v1.6 branch sets result["hex"] for the proof dict (cp_height > 0, singular), but the spec key for that dict is "header", not "hex" — "hex" is only correct for the plural blockchain.block.headers concatenated response.
Impact
Sparrow retries the same request 5+ times per wallet load before dropping the connection. The wallet never finishes loading.
blockchain.block.headerreturns wrong response format whencp_height = 0Summary
blockchain.block.headerwraps its result in a JSON object instead of returning a plain hex string whencp_heightis zero. This breaks Electrum wallet clients (confirmed with Sparrow) that expect the response format specified in the Electrum protocol.Observed behavior
{"jsonrpc":"2.0","id":37,"result":{"hex":"0000092090a327..."}}Expected behavior
{"jsonrpc":"2.0","id":37,"result":"0000092090a327..."}Protocol spec
Per the Electrum protocol spec:
cp_height = 0→ result is a plain hex stringcp_height > 0→ result is a dict withheader,branch, androotkeysRoot cause
blockchain_block_headers()insrc/protocols/electrum/protocol_electrum_headers.cppis the shared implementation for bothblockchain.block.headerandblockchain.block.headers. It unconditionally builds avalue_t{ object_t{} }for all code paths, including the single-header no-proof case that must return a plain string.A second related bug exists in the same function: the pre-v1.6 branch sets
result["hex"]for the proof dict (cp_height > 0, singular), but the spec key for that dict is"header", not"hex"—"hex"is only correct for the pluralblockchain.block.headersconcatenated response.Impact
Sparrow retries the same request 5+ times per wallet load before dropping the connection. The wallet never finishes loading.