Merge bitcoin/bitcoin#36471: bitcoin-util: print genesis hash in display order
What changed, and why it matters
This commit fixes a display bug in the new bitcoin-util getchainparams command. The genesis block hash was being printed backwards (byte-reversed) compared to how it is normally shown elsewhere in Bitcoin. The change makes the output consistent with bitcoin-cli getblockhash 0 and other RPC commands. This is a cosmetic/output-format fix, not a security issue.
No security action required. This is a user-facing output-format correction for a new command in v32.0. Consider backporting to v32.0 as the PR author suggests to avoid a breaking format change after release.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/bitcoin-util.cpp, the GetChainParams function previously used HexStr(consensus.hashGenesisBlock) to serialize the uint256 hash, which produces little-endian byte order. This caused the genesis hash to appear reversed compared to the standard block hash display order used by RPCs. The fix replaces HexStr() with consensus.hashGenesisBlock.GetHex(), which returns the hash in the conventional big-endian display order. Test fixture JSON files are updated to match the corrected output.
Changed components
src/bitcoin-util.cppbitcoin-util getchainparams commandtest/functional/data/util/getchainparams-*.json fixturesInspect captured patch +7 / −7
### src/bitcoin-util.cpp
@@ -166,7 +166,7 @@ static int GetChainParams(const std::vector<std::string>& args, std::string& str
UniValue result{UniValue::VOBJ};
result.pushKV("chain", params.GetChainTypeString());
result.pushKV("test_chain", params.IsTestChain());
- result.pushKV("genesis", HexStr(consensus.hashGenesisBlock));
+ result.pushKV("genesis", consensus.hashGenesisBlock.GetHex());
result.pushKV("subsidy_halving_interval", consensus.nSubsidyHalvingInterval);
if (consensus.signet_blocks) {
### test/functional/data/util/getchainparams-mainnet.json
@@ -1,7 +1,7 @@
{
"chain": "main",
"test_chain": false,
- "genesis": "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000",
+ "genesis": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"subsidy_halving_interval": 210000,
"pow": {
"limit": "00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
### test/functional/data/util/getchainparams-regtest.json
@@ -1,7 +1,7 @@
{
"chain": "regtest",
"test_chain": true,
- "genesis": "06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f",
+ "genesis": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
"subsidy_halving_interval": 150,
"pow": {
"limit": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
### test/functional/data/util/getchainparams-signet-custom.json
@@ -1,7 +1,7 @@
{
"chain": "signet",
"test_chain": true,
- "genesis": "f61eee3b63a380a477a063af32b2bbc97c9ff9f01f2c4225e973988108000000",
+ "genesis": "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6",
"subsidy_halving_interval": 210000,
"signet": {
"challenge": "512102f7561d208dd9ae99bf497273e16f389bdbd6c4742ddb8e6b216e64fa2928ad8f51ae"
### test/functional/data/util/getchainparams-signet.json
@@ -1,7 +1,7 @@
{
"chain": "signet",
"test_chain": true,
- "genesis": "f61eee3b63a380a477a063af32b2bbc97c9ff9f01f2c4225e973988108000000",
+ "genesis": "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6",
"subsidy_halving_interval": 210000,
"signet": {
"challenge": "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae"
### test/functional/data/util/getchainparams-testnet.json
@@ -1,7 +1,7 @@
{
"chain": "test",
"test_chain": true,
- "genesis": "43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000",
+ "genesis": "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
"subsidy_halving_interval": 210000,
"pow": {
"limit": "00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
### test/functional/data/util/getchainparams-testnet4.json
@@ -1,7 +1,7 @@
{
"chain": "testnet4",
"test_chain": true,
- "genesis": "43f08bdab050e35b567c864b91f47f50ae725ae2de53bcfbbaf284da00000000",
+ "genesis": "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043",
"subsidy_halving_interval": 210000,
"pow": {
"limit": "00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Why this scored 17/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.