bitcoin-util: print genesis hash in display order #36471

Manually merged
ViniciusCestarii merged 1 commit from util-getchainparams-genesis-order into master 2026-10-08 13:36:56 +00:00 AGit
ViniciusCestarii commented 2026-10-08 11:57:04 +00:00 (Migrated from github.com)

bitcoin-util getchainparams prints the genesis hash byte-reversed compared to getblockhash 0:

bitcoin-util getchainparams | grep genesis

"genesis": "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000",

bitcoin-cli getblockhash 0

000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

Use GetHex() instead of HexStr(), consistent with pow.limit in the same output and with the RPCs.

The command is new in v32.0 (#35736), so I believe this should be backported before final release to avoid changing the output format afterwards.

`bitcoin-util getchainparams` prints the genesis hash byte-reversed compared to `getblockhash 0`: ``` bitcoin-util getchainparams | grep genesis ``` "genesis": "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000", ``` bitcoin-cli getblockhash 0 ``` 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f Use `GetHex()` instead of `HexStr()`, consistent with `pow.limit` in the same output and with the RPCs. The command is new in v32.0 (#35736), so I believe this should be backported before final release to avoid changing the output format afterwards.
DrahtBot commented 2026-10-08 11:57:12 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK sedited, brunoerg, maflcko

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36471 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36471.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36471#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36471#pullrequestreview-5456242276), [brunoerg](https://github.com/bitcoin/bitcoin/pull/36471#pullrequestreview-5456496907), [maflcko](https://github.com/bitcoin/bitcoin/pull/36471#issuecomment-6059898953) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 282a05b8d10e317d2ce4b42b96ee8b13345804ea
Head: cc8285e8c98ac91a380eec899bab2aed5863a458

I found no actionable issues in this static review.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `282a05b8d10e317d2ce4b42b96ee8b13345804ea` Head: `cc8285e8c98ac91a380eec899bab2aed5863a458` I found no actionable issues in this static review. [Full review report](<https://review.fish.foo/traces/36471-cc8285e8c98ac91a380eec899bab2aed5863a458-581-1.html>)
sedited (Migrated from github.com) approved these changes 2026-10-08 12:02:22 +00:00
sedited (Migrated from github.com) left a comment
ACK cc8285e8c98ac91a380eec899bab2aed5863a458
brunoerg (Migrated from github.com) approved these changes 2026-10-08 12:24:31 +00:00
brunoerg (Migrated from github.com) left a comment

code review ACK cc8285e8c9

code review ACK cc8285e8c98ac91a380eec899bab2aed5863a458
maflcko commented 2026-10-08 12:30:22 +00:00 (Migrated from github.com)

In theory, one could use something like this to make it more explicit:

diff --git a/src/uint256.h b/src/uint256.h
index d722916..62bb228 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -123,2 +123,6 @@ public:
 
+// See GetHex(). If HexStr is intended, use HexStr(std::span{self}).
+template <unsigned int BITS>
+std::string HexStr(const base_blob<BITS>&) = delete;
+
 template <unsigned int BITS>

But it will be a bit verbose and I am not sure if it really helps.

In theory, one could use something like this to make it more explicit: ```diff diff --git a/src/uint256.h b/src/uint256.h index d722916..62bb228 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -123,2 +123,6 @@ public: +// See GetHex(). If HexStr is intended, use HexStr(std::span{self}). +template <unsigned int BITS> +std::string HexStr(const base_blob<BITS>&) = delete; + template <unsigned int BITS> ``` But it will be a bit verbose and I am not sure if it really helps.
maflcko commented 2026-10-08 12:30:36 +00:00 (Migrated from github.com)

lgtm ACK cc8285e8c9

lgtm ACK cc8285e8c98ac91a380eec899bab2aed5863a458
fanquake commented 2026-10-08 20:57:52 +00:00 (Migrated from github.com)

Backported to 32.x in #36427.

Backported to `32.x` in #36427.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36471
No description provided.