diff --git a/libraries/fc b/libraries/fc index 0dbf7ffc23..e310159ede 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 0dbf7ffc23162155fa59968e191c52c94ee11032 +Subproject commit e310159ede5a62a14ec6a17d2d45d83d065af2cf diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index aeebb64eb8..da06a23598 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -663,6 +663,12 @@ class wallet_api */ bool load_wallet_file(string wallet_filename = ""); + /** Quitting from BitShares wallet. + * + * The current wallet will be closed. + */ + void quit(); + /** Saves the current wallet to the given filename. * * @warning This does not change the wallet filename that will be used for future @@ -1848,4 +1854,5 @@ FC_API( graphene::wallet::wallet_api, (blind_history) (receive_blind_transfer) (get_order_book) + (quit) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 8b61b74cf2..d6d222e065 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -774,6 +774,14 @@ class wallet_api_impl return true; } + + void quit() + { + ilog( "Quitting Cli Wallet ..." ); + + throw fc::canceled_exception(); + } + void save_wallet_file(string wallet_filename = "") { // @@ -3781,6 +3789,11 @@ bool wallet_api::load_wallet_file( string wallet_filename ) return my->load_wallet_file( wallet_filename ); } +void wallet_api::quit() +{ + my->quit(); +} + void wallet_api::save_wallet_file( string wallet_filename ) { my->save_wallet_file( wallet_filename ); diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 672a8b8600..88a4ef9884 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -221,6 +221,34 @@ BOOST_AUTO_TEST_CASE( cli_connect ) app1->shutdown(); } +//////////////// +// Start a server and connect using the same calls as the CLI +// Quit wallet and be sure that file was saved correctly +//////////////// +BOOST_AUTO_TEST_CASE( cli_quit ) +{ + using namespace graphene::chain; + using namespace graphene::app; + std::shared_ptr app1; + try { + BOOST_TEST_MESSAGE("Testing wallet connection and quit command."); + + fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); + + int server_port_number = 0; + app1 = start_application(app_dir, server_port_number); + + // connect to the server + client_connection con(app1, app_dir, server_port_number); + + BOOST_CHECK_THROW( con.wallet_api_ptr->quit(), fc::canceled_exception ); + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } + app1->shutdown(); + } + /////////////////////// // Start a server and connect using the same calls as the CLI // Vote for two witnesses, and make sure they both stay there