From 6372b25dea2e2a38f6665ae425a5676c1adce909 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 20 Aug 2015 18:41:54 -0400 Subject: [PATCH] cli_wallet: Expose get_private_key() --- libraries/wallet/include/graphene/wallet/wallet.hpp | 7 +++++++ libraries/wallet/wallet.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index ac1c334b..68b191e9 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -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) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 0eefe792..1c211d32 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -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(); } catch ( ... ){}