diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index a40f38d4..4d109171 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -580,6 +580,11 @@ class wallet_api */ brain_key_info suggest_brain_key()const; + /** + * @param role - active | owner | memo + */ + pair get_private_key_from_password( string account, string role, string password )const; + /** Converts a signed_transaction in JSON form to its binary representation. * * TODO: I don't see a broadcast_transaction() function, do we need one? @@ -1656,6 +1661,7 @@ FC_API( graphene::wallet::wallet_api, (import_account_keys) (import_balance) (suggest_brain_key) + (get_private_key_from_password) (register_account) (upgrade_account) (create_account_with_brain_key) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 65d21b9d..d164612e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3382,6 +3382,14 @@ brain_key_info wallet_api::suggest_brain_key()const return result; } +pair wallet_api::get_private_key_from_password( string account, string role, string password )const { + auto seed = password + account + role; + FC_ASSERT( seed.size() ); + auto secret = fc::sha256::hash( seed.c_str(), seed.size() ); + auto priv = fc::ecc::private_key::regenerate( secret ); + return std::make_pair( public_key_type( priv.get_public_key() ), key_to_wif( priv ) ); +} + string wallet_api::serialize_transaction( signed_transaction tx )const { return fc::to_hex(fc::raw::pack(tx));