diff --git a/src/parse/target.cpp b/src/parse/target.cpp index 825871cc..e8903396 100644 --- a/src/parse/target.cpp +++ b/src/parse/target.cpp @@ -104,8 +104,23 @@ code parse_target(request_t& out, const std::string_view& path) NOEXCEPT const auto base16 = to_base16(segments[segment++]); if (!base16) return error::invalid_hash; - method = "address"; params["hash"] = base16; + if (segment == segments.size()) + { + method = "address"; + } + else + { + const auto subcomponent = segments[segment++]; + if (subcomponent == "confirmed") + method = "address_confirmed"; + else if (subcomponent == "unconfirmed") + method = "address_unconfirmed"; + else if (subcomponent == "balance") + method = "address_balance"; + else + return error::invalid_subcomponent; + } } else if (target == "input") { diff --git a/src/protocols/protocol_explore.cpp b/src/protocols/protocol_explore.cpp index 5aa0f0fb..c2882dad 100644 --- a/src/protocols/protocol_explore.cpp +++ b/src/protocols/protocol_explore.cpp @@ -1050,7 +1050,7 @@ bool protocol_explore::handle_get_address_unconfirmed(const code& ec, // TODO: there are currently no unconfirmed txs. - send_not_found(); + send_not_implemented(); return true; } diff --git a/test/parse/target.cpp b/test/parse/target.cpp index 55be09c5..b702e6fe 100644 --- a/test/parse/target.cpp +++ b/test/parse/target.cpp @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__block_height_invalid_height__invalid_n BOOST_AUTO_TEST_CASE(parse__parse_target__block_height_invalid_component__invalid_component) { request_t out{}; - BOOST_REQUIRE_EQUAL(parse_target(out, "/v3/block/height/123/extra"), node::error::invalid_component); + BOOST_REQUIRE_EQUAL(parse_target(out, "/v3/block/height/123/invalid"), node::error::invalid_component); } // block/hash @@ -419,7 +419,7 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__transaction_invalid_hash__invalid_hash BOOST_AUTO_TEST_CASE(parse__parse_target__tx_invalid_component__invalid_component) { - const std::string path = "/v3/tx/0000000000000000000000000000000000000000000000000000000000000000/extra"; + const std::string path = "/v3/tx/0000000000000000000000000000000000000000000000000000000000000000/invalid"; request_t out{}; BOOST_REQUIRE_EQUAL(parse_target(out, path), node::error::invalid_component); } @@ -757,7 +757,7 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__output_script_valid__expected) BOOST_AUTO_TEST_CASE(parse__parse_target__output_script_invalid_subcomponent__invalid_subcomponent) { - const std::string path = "/v3/output/0000000000000000000000000000000000000000000000000000000000000000/3/extra"; + const std::string path = "/v3/output/0000000000000000000000000000000000000000000000000000000000000000/3/invalid"; request_t out{}; BOOST_REQUIRE_EQUAL(parse_target(out, path), node::error::invalid_subcomponent); } @@ -885,13 +885,18 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__address_invalid_hash__invalid_hash) BOOST_REQUIRE_EQUAL(parse_target(out, "/v3/address/invalidhex"), node::error::invalid_hash); } -BOOST_AUTO_TEST_CASE(parse__parse_target__address_extra_segment__extra_segment) +BOOST_AUTO_TEST_CASE(parse__parse_target__address_invalid_subcomponent__invalid_subcomponent) { - const std::string path = "/v3/address/0000000000000000000000000000000000000000000000000000000000000000/extra"; + const std::string path = "/v3/address/0000000000000000000000000000000000000000000000000000000000000000/invalid"; request_t out{}; - BOOST_REQUIRE_EQUAL(parse_target(out, path), node::error::extra_segment); + BOOST_REQUIRE_EQUAL(parse_target(out, path), node::error::invalid_subcomponent); } +// TODO: +// address/confirmed +// address/unconfirmed +// address/balance + // block_filter/height BOOST_AUTO_TEST_CASE(parse__parse_target__block_filter_height_valid__expected) @@ -920,7 +925,7 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__block_filter_height_valid__expected) BOOST_AUTO_TEST_CASE(parse__parse_target__block_filter_height_invalid_subcomponent__invalid_subcomponent) { request_t out{}; - BOOST_REQUIRE_EQUAL(parse_target(out, "/v3/block/height/123/filter/42/extra"), node::error::invalid_subcomponent); + BOOST_REQUIRE_EQUAL(parse_target(out, "/v3/block/height/123/filter/42/invalid"), node::error::invalid_subcomponent); } // block_filter/hash @@ -956,7 +961,7 @@ BOOST_AUTO_TEST_CASE(parse__parse_target__block_filter_hash_valid__expected) BOOST_AUTO_TEST_CASE(parse__parse_target__block_filter_hash_invalid_subcomponent__invalid_subcomponent) { - const std::string path = "/v3/block/hash/0000000000000000000000000000000000000000000000000000000000000000/filter/42/extra"; + const std::string path = "/v3/block/hash/0000000000000000000000000000000000000000000000000000000000000000/filter/42/invalid"; request_t out{}; BOOST_REQUIRE_EQUAL(parse_target(out, path), node::error::invalid_subcomponent); }