Skip to content

Commit

Permalink
Add "about" api call to wallet. Fix cryptonomex#339
Browse files Browse the repository at this point in the history
  • Loading branch information
wackou committed Nov 25, 2015
1 parent c3dd6c3 commit 8602954
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libraries/wallet/include/graphene/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ class wallet_api
fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const;

variant info();
/** Returns info such as client version, git version of graphene/fc, version of boost, openssl.
* @returns compile time info and client and dependencies versions
*/
variant_object about() const;
optional<signed_block_with_info> get_block( uint32_t num );
/** Returns the number of accounts registered on the blockchain
* @returns the number of registered accounts
Expand Down Expand Up @@ -1462,6 +1466,7 @@ FC_API( graphene::wallet::wallet_api,
(help)
(gethelp)
(info)
(about)
(begin_builder_transaction)
(add_operation_to_builder_transaction)
(replace_operation_in_builder_transaction)
Expand Down
46 changes: 46 additions & 0 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <string>
#include <list>

#include <boost/version.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/replace.hpp>

#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm_ext/erase.hpp>
#include <boost/range/algorithm/unique.hpp>
Expand All @@ -41,6 +45,7 @@
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/hashed_index.hpp>

#include <fc/git_revision.hpp>
#include <fc/io/fstream.hpp>
#include <fc/io/json.hpp>
#include <fc/io/stdio.hpp>
Expand All @@ -55,6 +60,7 @@
#include <graphene/app/api.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/utilities/git_revision.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/utilities/words.hpp>
#include <graphene/wallet/wallet.hpp>
Expand Down Expand Up @@ -506,6 +512,41 @@ class wallet_api_impl
result["active_committee_members"] = global_props.active_committee_members;
return result;
}

variant_object about() const
{
string client_version( graphene::utilities::git_revision_description );
const size_t pos = client_version.find( '/' );
if( pos != string::npos && client_version.size() > pos )
client_version = client_version.substr( pos + 1 );

fc::mutable_variant_object result;
//result["blockchain_name"] = BLOCKCHAIN_NAME;
//result["blockchain_description"] = BTS_BLOCKCHAIN_DESCRIPTION;
result["client_version"] = client_version;
result["graphene_revision"] = graphene::utilities::git_revision_sha;
result["graphene_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( graphene::utilities::git_revision_unix_timestamp ) );
result["fc_revision"] = fc::git_revision_sha;
result["fc_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( fc::git_revision_unix_timestamp ) );
result["compile_date"] = "compiled on " __DATE__ " at " __TIME__;
result["boost_version"] = boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".");
result["openssl_version"] = OPENSSL_VERSION_TEXT;

std::string bitness = boost::lexical_cast<std::string>(8 * sizeof(int*)) + "-bit";
#if defined(__APPLE__)
std::string os = "osx";
#elif defined(__linux__)
std::string os = "linux";
#elif defined(_MSC_VER)
std::string os = "win32";
#else
std::string os = "other";
#endif
result["build"] = os + " " + bitness;

return result;
}

chain_property_object get_chain_properties() const
{
return _remote_db->get_chain_properties();
Expand Down Expand Up @@ -2866,6 +2907,11 @@ variant wallet_api::info()
return my->info();
}

variant_object wallet_api::about() const
{
return my->about();
}

fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const
{
return detail::derive_private_key( prefix_string, sequence_number );
Expand Down

0 comments on commit 8602954

Please sign in to comment.