cli_wallet: Expose get_private_key()

This commit is contained in:
theoreticalbts 2015-08-20 18:41:54 -04:00
parent 4228360409
commit 6372b25dea
2 changed files with 12 additions and 0 deletions

View file

@ -356,6 +356,12 @@ class wallet_api
*/
string get_wallet_filename() const;
/**
* Get the WIF private key corresponding to a public key. The
* private key must already be in the wallet.
*/
string get_private_key( public_key_type pubkey )const;
/**
* @ingroup Transaction Builder API
*/
@ -1301,6 +1307,7 @@ FC_API( graphene::wallet::wallet_api,
(get_global_properties)
(get_dynamic_global_properties)
(get_object)
(get_private_key)
(load_wallet_file)
(normalize_brain_key)
(get_limit_orders)

View file

@ -2800,6 +2800,11 @@ string wallet_api::get_key_label( public_key_type key )const
return string();
}
string wallet_api::get_private_key( public_key_type pubkey )const
{
return key_to_wif( my->get_private_key( pubkey ) );
}
public_key_type wallet_api::get_public_key( string label )const
{
try { return fc::variant(label).as<public_key_type>(); } catch ( ... ){}