diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 105b948b..2d2a5a02 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -515,5 +515,23 @@ namespace graphene { namespace app { return result; } + /** + * @return all key_ids that have been registered for a given address. + */ + vector database_api::get_keys_for_address( const address& a )const + { try { + vector result; + const auto& idx = _db.get_index_type(); + const auto& aidx = idx.indices().get(); + auto itr = aidx.find(a); + + while( itr != aidx.end() && itr->key_address() == a ) + { + result.push_back( itr->id ); + ++itr; + } + return result; + } FC_CAPTURE_AND_RETHROW( (a) ) } + } } // graphene::app diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index c081ef17..024b0697 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -242,6 +242,11 @@ namespace graphene { namespace app { */ vector get_account_references( object_id_type key_or_account_id )const; + /** + * @return all key_ids that have been registered for a given address. + */ + vector get_keys_for_address( const address& a )const; + private: /** called every time a block is applied to report the objects that were changed */ void on_objects_changed(const vector& ids); @@ -383,6 +388,7 @@ FC_API(graphene::app::database_api, (get_transaction_hex) (get_proposed_transactions) (get_account_references) + (get_keys_for_address) ) FC_API(graphene::app::history_api, (get_account_history)(get_market_history)(get_market_history_buckets)) FC_API(graphene::app::network_api, (broadcast_transaction)(add_node)(get_connected_peers))