From b4fddebf24064aa5d91156b4c55447c56130f733 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 6 Aug 2015 16:09:58 -0400 Subject: [PATCH] Remove broken, unused cli_full_wallet --- docs | 2 +- programs/CMakeLists.txt | 1 - programs/cli_full_wallet/CMakeLists.txt | 25 --- programs/cli_full_wallet/main.cpp | 270 ------------------------ 4 files changed, 1 insertion(+), 297 deletions(-) delete mode 100644 programs/cli_full_wallet/CMakeLists.txt delete mode 100644 programs/cli_full_wallet/main.cpp diff --git a/docs b/docs index f7f73f52..3efdc9bf 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f7f73f52a5a60a1606c05a3e8a2d6a5df32b579c +Subproject commit 3efdc9bfa75c6a35c2ff40c48ce3aa0390322dc9 diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 8e143dcc..32a80b91 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory( cli_wallet ) -add_subdirectory( cli_full_wallet ) add_subdirectory( witness_node ) add_subdirectory( js_operation_serializer ) add_subdirectory( size_checker ) diff --git a/programs/cli_full_wallet/CMakeLists.txt b/programs/cli_full_wallet/CMakeLists.txt deleted file mode 100644 index 3f7c72f1..00000000 --- a/programs/cli_full_wallet/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -add_executable( cli_full_wallet main.cpp ) -if( UNIX AND NOT APPLE ) - set(rt_library rt ) -endif() - -find_package( Gperftools QUIET ) -if( GPERFTOOLS_FOUND ) - message( STATUS "Found gperftools; compiling cli_full_wallet with TCMalloc") - list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc ) -endif() - -target_link_libraries( cli_full_wallet - PRIVATE graphene_witness graphene_account_history graphene_market_history graphene_app graphene_net graphene_chain graphene_egenesis_full graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) - -if(MSVC) - set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) -endif(MSVC) - -install( TARGETS - cli_full_wallet - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/programs/cli_full_wallet/main.cpp b/programs/cli_full_wallet/main.cpp deleted file mode 100644 index 74765be3..00000000 --- a/programs/cli_full_wallet/main.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#ifndef WIN32 -#include -#endif - -using namespace graphene::app; -using namespace graphene::chain; -using namespace graphene::utilities; -using namespace graphene::wallet; -using namespace graphene; -using namespace std; -namespace bpo = boost::program_options; - -int main( int argc, char** argv ) -{ - try { - app::application node; - - bpo::options_description cli; - cli.add_options() - ("help,h", "Print this help message and exit.") - ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on") - ("rpc-tls-endpoint,t", bpo::value()->implicit_value("127.0.0.1:8092"), "Endpoint for wallet websocket TLS RPC to listen on") - ("rpc-tls-certificate,c", bpo::value()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC") - ("rpc-http-endpoint,h", bpo::value()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on") - ("daemon,d", "Run the wallet in daemon mode" ) - ("wallet-file,W", bpo::value()->implicit_value("wallet.json"), "wallet to load"); - - bpo::options_description app_options("Graphene Witness Node"); - bpo::options_description cfg_options("Graphene Witness Node"); - app_options.add_options() - ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), "Directory containing databases, configuration file, etc.") - ; - - bpo::variables_map options; - - auto witness_plug = node.register_plugin(); - auto history_plug = node.register_plugin(); - auto market_history_plug = node.register_plugin(); - - try - { - bpo::options_description cfg; - node.set_program_options(cli, cfg); - app_options.add(cli); - cfg_options.add(cfg); - bpo::store(bpo::parse_command_line(argc, argv, app_options), options); - } - catch (const boost::program_options::error& e) - { - std::cerr << "Error parsing command line: " << e.what() << "\n"; - return 1; - } - - if( options.count("help") ) - { - std::cout << cli << "\n"; - return 0; - } - - fc::path data_dir; - fc::logging_config cfg; - fc::path log_dir = data_dir / "logs"; - - fc::file_appender::config ac; - ac.filename = log_dir / "rpc" / "rpc.log"; - ac.flush = true; - ac.rotate = true; - ac.rotation_interval = fc::hours( 1 ); - ac.rotation_limit = fc::days( 1 ); - - std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n"; - - cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(fc::console_appender::config()))); - cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac))); - - cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; - cfg.loggers.front().level = fc::log_level::info; - cfg.loggers.front().appenders = {"default"}; - cfg.loggers.back().level = fc::log_level::debug; - cfg.loggers.back().appenders = {"rpc"}; - - //fc::configure_logging( cfg ); - - fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); - - idump( (key_to_wif( committee_private_key ) ) ); - - fc::ecc::private_key nathan_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); - idump( (key_to_wif( nathan_private_key ) ) ); - - // - // TODO: We read wallet_data twice, once in main() to grab the - // socket info, again in wallet_api when we do - // load_wallet_file(). Seems like this could be better - // designed. - // - wallet_data wdata; - - fc::path wallet_file( options.count("wallet-file") ? options.at("wallet-file").as() : "wallet.json"); - if( fc::exists( wallet_file ) ) - wdata = fc::json::from_file( wallet_file ).as(); - - - - node.initialize(data_dir, options); - node.initialize_plugins( options ); - - node.startup(); - node.startup_plugins(); - - ilog("Started witness node on a chain with ${h} blocks.", ("h", node.chain_database()->head_block_num())); - - - // auto remote_api = apic->get_remote_api< login_api >(1); - // FC_ASSERT( remote_api->login( wdata.ws_user, wdata.ws_password ) ); - - auto login = std::make_shared( std::ref(node) ); - login->login( "", "" ); - auto wapiptr = std::make_shared(login);//remote_api); - wapiptr->set_wallet_filename( wallet_file.generic_string() ); - wapiptr->load_wallet_file(); - - fc::api wapi(wapiptr); - - auto wallet_cli = std::make_shared(); - for( auto& name_formatter : wapiptr->get_result_formatters() ) - wallet_cli->format_result( name_formatter.first, name_formatter.second ); - - if( wapiptr->is_new() ) - { - std::cout << "Please use the set_password method to initialize a new wallet before continuing\n"; - wallet_cli->set_prompt( "new >>> " ); - } else - wallet_cli->set_prompt( "locked >>> " ); - - boost::signals2::scoped_connection locked_connection(wapiptr->lock_changed.connect([&](bool locked) { - wallet_cli->set_prompt( locked ? "locked >>> " : "unlocked >>> " ); - })); - - auto _websocket_server = std::make_shared(); - if( options.count("rpc-endpoint") ) - { - _websocket_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ - std::cout << "here... \n"; - wlog("." ); - auto wsc = std::make_shared(*c); - wsc->register_api(wapi); - c->set_session_data( wsc ); - }); - ilog( "Listening for incoming RPC requests on ${p}", ("p", options.at("rpc-endpoint").as() )); - _websocket_server->listen( fc::ip::endpoint::from_string(options.at("rpc-endpoint").as()) ); - _websocket_server->start_accept(); - } - - string cert_pem = "server.pem"; - if( options.count( "rpc-tls-certificate" ) ) - cert_pem = options.at("rpc-tls-certificate").as(); - - auto _websocket_tls_server = std::make_shared(cert_pem); - if( options.count("rpc-tls-endpoint") ) - { - _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ - auto wsc = std::make_shared(*c); - wsc->register_api(wapi); - c->set_session_data( wsc ); - }); - ilog( "Listening for incoming TLS RPC requests on ${p}", ("p", options.at("rpc-tls-endpoint").as() )); - _websocket_tls_server->listen( fc::ip::endpoint::from_string(options.at("rpc-tls-endpoint").as()) ); - _websocket_tls_server->start_accept(); - } - - auto _http_server = std::make_shared(); - if( options.count("rpc-http-endpoint" ) ) - { - ilog( "Listening for incoming HTTP RPC requests on ${p}", ("p", options.at("rpc-http-endpoint").as() ) ); - _http_server->listen( fc::ip::endpoint::from_string( options.at( "rpc-http-endpoint" ).as() ) ); - // - // due to implementation, on_request() must come AFTER listen() - // - _http_server->on_request( - [&]( const fc::http::request& req, const fc::http::server::response& resp ) - { - std::shared_ptr< fc::rpc::http_api_connection > conn = - std::make_shared< fc::rpc::http_api_connection>(); - conn->register_api( wapi ); - conn->on_request( req, resp ); - } ); - } - - if( !options.count( "daemon" ) ) - { - wallet_cli->register_api( wapi ); - wallet_cli->start(); - wallet_cli->wait(); - } - else - { - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); -#ifdef __unix__ - fc::set_signal_handler([&exit_promise](int signal) { - exit_promise->set_value(signal); - }, SIGINT); -#endif - - ilog( "Entering Daemon Mode, ^C to exit" ); - exit_promise->wait(); - } - - wapi->save_wallet_file(wallet_file.generic_string()); - locked_connection.disconnect(); - node.shutdown_plugins(); - } - catch ( const fc::exception& e ) - { - std::cout << e.to_detail_string() << "\n"; - return -1; - } - return 0; -}