Skip to content

Commit 5bbc83f

Browse files
committed
Reverse byte order on explore address to match electrum.
1 parent eb8d9d3 commit 5bbc83f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/parse/target.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ static hash_cptr to_hash(const std::string_view& token) NOEXCEPT
4646
emplace_shared<const hash_digest>(std::move(out)) : hash_cptr{};
4747
}
4848

49-
static hash_cptr to_base16(const std::string_view& token) NOEXCEPT
50-
{
51-
hash_digest out{};
52-
return decode_base16(out, token) ?
53-
emplace_shared<const hash_digest>(std::move(out)) : hash_cptr{};
54-
}
49+
////static hash_cptr to_base16(const std::string_view& token) NOEXCEPT
50+
////{
51+
//// hash_digest out{};
52+
//// return decode_base16(out, token) ?
53+
//// emplace_shared<const hash_digest>(std::move(out)) : hash_cptr{};
54+
////}
5555

5656
code parse_target(request_t& out, const std::string_view& path) NOEXCEPT
5757
{
@@ -100,8 +100,8 @@ code parse_target(request_t& out, const std::string_view& path) NOEXCEPT
100100
if (segment == segments.size())
101101
return error::missing_hash;
102102

103-
// address hash is a single sha256, and conventionally not reversed.
104-
const auto base16 = to_base16(segments[segment++]);
103+
// address hash is a single sha256, in reversed display endianness.
104+
const auto base16 = to_hash(segments[segment++]);
105105
if (!base16) return error::invalid_hash;
106106

107107
params["hash"] = base16;

test/parse/target.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,9 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__output_spenders_extra_segment__extra_s
847847

848848
// address
849849

850-
BOOST_AUTO_TEST_CASE(parse__parse_target__address_valid__unreversed_expected)
850+
BOOST_AUTO_TEST_CASE(parse__parse_target__address_valid__reversed_expected)
851851
{
852-
const std::string path = "/v255/address/4200000000000000000000000000000000000000000000000000000000000000";
852+
const std::string path = "/v255/address/0000000000000000000000000000000000000000000000000000000000000042";
853853

854854
request_t request{};
855855
BOOST_REQUIRE(!parse_target(request, path));

0 commit comments

Comments
 (0)