|
|
|
@ -3763,6 +3763,57 @@ namespace tools
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
bool wallet_rpc_server::on_validate_address(const wallet_rpc::COMMAND_RPC_VALIDATE_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_VALIDATE_ADDRESS::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
|
|
|
|
{
|
|
|
|
|
cryptonote::address_parse_info info;
|
|
|
|
|
static const struct { cryptonote::network_type type; const char *stype; } net_types[] = {
|
|
|
|
|
{ cryptonote::MAINNET, "mainnet" },
|
|
|
|
|
{ cryptonote::TESTNET, "testnet" },
|
|
|
|
|
{ cryptonote::STAGENET, "stagenet" },
|
|
|
|
|
};
|
|
|
|
|
for (const auto &net_type: net_types)
|
|
|
|
|
{
|
|
|
|
|
if (!req.any_net_type && net_type.type != m_wallet->nettype())
|
|
|
|
|
continue;
|
|
|
|
|
if (req.allow_openalias)
|
|
|
|
|
{
|
|
|
|
|
std::string address;
|
|
|
|
|
res.valid = get_account_address_from_str_or_url(info, net_type.type, req.address,
|
|
|
|
|
[&er, &address](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
|
|
|
|
|
if (!dnssec_valid)
|
|
|
|
|
{
|
|
|
|
|
er.message = std::string("Invalid DNSSEC for ") + url;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
if (addresses.empty())
|
|
|
|
|
{
|
|
|
|
|
er.message = std::string("No Monero address found at ") + url;
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
address = addresses[0];
|
|
|
|
|
return address;
|
|
|
|
|
});
|
|
|
|
|
if (res.valid)
|
|
|
|
|
res.openalias_address = address;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
res.valid = cryptonote::get_account_address_from_str(info, net_type.type, req.address);
|
|
|
|
|
}
|
|
|
|
|
if (res.valid)
|
|
|
|
|
{
|
|
|
|
|
res.integrated = info.has_payment_id;
|
|
|
|
|
res.subaddress = info.is_subaddress;
|
|
|
|
|
res.nettype = net_type.stype;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
|
|
|
|
|
er.message = std::string("Invalid address");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
bool wallet_rpc_server::on_get_version(const wallet_rpc::COMMAND_RPC_GET_VERSION::request& req, wallet_rpc::COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
|
|
|
|
{
|
|
|
|
|
res.version = WALLET_RPC_VERSION;
|
|
|
|
|