1
0
Fork 0
forked from lthn/blockchain

added api for validating address

This commit is contained in:
cryptozoidberg 2020-06-05 20:17:05 +02:00
parent fc627bbfe4
commit ccedbe8781
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
2 changed files with 20 additions and 1 deletions

View file

@ -333,6 +333,24 @@ namespace plain_wallet
return epee::serialization::store_t_to_json(ok_response);
}
std::string get_address_info(const std::string& addr)
{
currency::account_public_address apa = AUTO_VAL_INIT(apa);
currency::payment_id_t pid = AUTO_VAL_INIT(pid);
if(!currency::get_account_address_and_payment_id_from_str(apa, pid, addr))
{
error_response err_result = AUTO_VAL_INIT(err_result);
err_result.error.code = API_RETURN_CODE_BAD_ARG;
return epee::serialization::store_t_to_json(err_result);
}
//lazy to make struct for it
std::stringstream res;
res << "{ \"valid\": true, \"auditable\" : "
<< (apa.flags&ACCOUNT_PUBLIC_ADDRESS_FLAG_AUDITABLE ? "true" : "false")
<< "\"payment_is\" : " << (pid.size() ? "true" : "false") << "}";
return res.str();
}
std::string open(const std::string& path, const std::string& password)
{
GET_INSTANCE_PTR(inst_ptr);

View file

@ -16,6 +16,7 @@ namespace plain_wallet
std::string get_version();
std::string get_wallet_files();
std::string delete_wallet(const std::string& file_name);
std::string get_address_info(const std::string& addr);
std::string get_appconfig(const std::string& encryption_key);
std::string set_appconfig(const std::string& conf_str, const std::string& encryption_key);
@ -27,7 +28,7 @@ namespace plain_wallet
std::string open(const std::string& path, const std::string& password);
std::string restore(const std::string& seed, const std::string& path, const std::string& password);
std::string generate(const std::string& path, const std::string& password);
std::string get_opened_wallets();
std::string get_opened_wallets();
std::string get_wallet_status(hwallet h);
std::string close_wallet(hwallet h);