diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 8611f4fc..0910cc83 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -1155,4 +1155,13 @@ namespace graphene { namespace app { return result; } + optional database_api::get_account_by_name( string name )const + { + const auto& idx = _db.get_index_type().indices().get(); + auto itr = idx.find(name); + if (itr != idx.end()) + return *itr; + return optional(); + } + } } // graphene::app diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index f22534b8..1da694de 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -110,6 +110,8 @@ namespace graphene { namespace app { * This function has semantics identical to @ref get_objects */ vector> lookup_account_names(const vector& account_names)const; + optional get_account_by_name( string name )const; + /** * @brief Get a list of assets by symbol * @param asset_symbols Symbols or stringified IDs of the assets to retrieve @@ -515,6 +517,7 @@ FC_API(graphene::app::database_api, (get_accounts) (get_assets) (lookup_account_names) + (get_account_by_name) (get_account_count) (lookup_accounts) (get_full_accounts)