Skip to content

Commit

Permalink
fix issue mvs-org#226: verifyaddress returns a poorly JSON-formatted …
Browse files Browse the repository at this point in the history
…response
  • Loading branch information
xiaozongyuan authored and Jowen committed Jan 12, 2018
1 parent 3cd1cdf commit 0841071
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class validateaddress: public command_extension
)
(
"PAYMENT_ADDRESS",
value<bc::wallet::payment_address>(&argument_.address),
value<std::string>(&argument_.address),
"Valid payment address. If not specified the address is read from STDIN."
);

Expand All @@ -79,7 +79,7 @@ class validateaddress: public command_extension

struct argument
{
bc::wallet::payment_address address;
std::string address;
} argument_;

struct option
Expand Down
10 changes: 6 additions & 4 deletions src/lib/explorer/extensions/commands/validateaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ console_result validateaddress::invoke (Json::Value& jv_output,
libbitcoin::server::server_node& node)
{
std::string version_info;
std::string message{"valid address "};
std::string message{"valid address"};
bool is_valid{true};

auto& blockchain = node.chain_impl();
wallet::payment_address payment_address(argument_.address);

if (!blockchain.chain_settings().use_testnet_rules && argument_.address.version() == 0x32) {
if (!blockchain.chain_settings().use_testnet_rules && payment_address.version() == 0x32) {
version_info = "p2kh(main-net)";
} else if (blockchain.chain_settings().use_testnet_rules && argument_.address.version() == 0x7f ) {
} else if (blockchain.chain_settings().use_testnet_rules && payment_address.version() == 0x7f ) {
version_info = "p2kh(test-net)";
} else if (argument_.address.version() == 0x05 ) {
} else if (payment_address.version() == 0x05 ) {
version_info = "p2sh(multi-signature)";
} else {
version_info = "none";
message = "invalid address!";
is_valid = false;
}
Expand Down

0 comments on commit 0841071

Please sign in to comment.