From c269dacc2ce3faac9d53093af8f3138aef2eaedd Mon Sep 17 00:00:00 2001 From: echennells Date: Fri, 13 Nov 2026 18:59:19 +0000 Subject: [PATCH] Encode the rest block hash by height text as a hash. The .hex form of /rest/blockhashbyheight returned the hash bytes in serialized order. bitcoind returns the hash in display order, the same string as the .json form. --- src/protocols/bitcoind/protocol_bitcoind_rest.cpp | 2 +- test/protocols/bitcoind/bitcoind_rest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocols/bitcoind/protocol_bitcoind_rest.cpp b/src/protocols/bitcoind/protocol_bitcoind_rest.cpp index 10ea221f..292b85b6 100644 --- a/src/protocols/bitcoind/protocol_bitcoind_rest.cpp +++ b/src/protocols/bitcoind/protocol_bitcoind_rest.cpp @@ -302,7 +302,7 @@ bool protocol_bitcoind_rest::handle_get_block_hash(const code& ec, send_chunk(to_chunk(hash)); return true; case text: - send_text(encode_base16(hash)); + send_text(encode_hash(hash)); return true; case json: send_json(object{ { "blockhash", encode_hash(hash) } }); diff --git a/test/protocols/bitcoind/bitcoind_rest.cpp b/test/protocols/bitcoind/bitcoind_rest.cpp index cbcf4346..db8bf04f 100644 --- a/test/protocols/bitcoind/bitcoind_rest.cpp +++ b/test/protocols/bitcoind/bitcoind_rest.cpp @@ -312,7 +312,7 @@ BC_AUTO_TEST_CASE(bitcoind_rest__blockhashbyheight_bin__height_five__block5) BC_AUTO_TEST_CASE(bitcoind_rest__blockhashbyheight_hex__height_five__block5) { - BC_REQUIRE_EQUAL(rest_text("/rest/blockhashbyheight/5.hex"), encode_base16(test::block5_hash) + "\n"); + BC_REQUIRE_EQUAL(rest_text("/rest/blockhashbyheight/5.hex"), block5 + "\n"); } BC_AUTO_TEST_CASE(bitcoind_rest__blockhashbyheight_above_top__not_found)