diff --git a/main.cpp b/main.cpp index f448062..94dca26 100644 --- a/main.cpp +++ b/main.cpp @@ -24,8 +24,9 @@ int main(int ac, const char* av[]) { // get command line options xmreg::CmdLineOptions opts {ac, av}; - auto help_opt = opts.get_option("help"); - auto testnet_opt = opts.get_option("testnet"); + auto help_opt = opts.get_option("help"); + auto testnet_opt = opts.get_option("testnet"); + auto enable_pusher_opt = opts.get_option("enable-pusher"); // if help was chosen, display help text and finish if (*help_opt) @@ -33,13 +34,15 @@ int main(int ac, const char* av[]) { return EXIT_SUCCESS; } - bool testnet {*testnet_opt}; + bool testnet {*testnet_opt}; + bool enable_pusher {*enable_pusher_opt}; auto port_opt = opts.get_option("port"); auto bc_path_opt = opts.get_option("bc-path"); auto custom_db_path_opt = opts.get_option("custom-db-path"); auto deamon_url_opt = opts.get_option("deamon-url"); + //cast port number in string to uint16 uint16_t app_port = boost::lexical_cast(*port_opt); @@ -107,10 +110,12 @@ int main(int ac, const char* av[]) { // create instance of page class which // contains logic for the website - xmreg::page xmrblocks(&mcore, core_storage, + xmreg::page xmrblocks(&mcore, + core_storage, deamon_url, custom_db_path_str, - testnet); + testnet, + enable_pusher); // crow instance crow::SimpleApp app; diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index 291adbb..9252257 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -25,6 +25,8 @@ namespace xmreg "produce help message") ("testnet,t", value()->default_value(false)->implicit_value(true), "use testnet blockchain") + ("enable-pusher", value()->default_value(false)->implicit_value(true), + "enable pushing signed tx") ("port,p", value()->default_value("8081"), "default port") ("bc-path,b", value(), diff --git a/src/page.h b/src/page.h index e0f6e8a..12772ee 100644 --- a/src/page.h +++ b/src/page.h @@ -251,17 +251,21 @@ class page { bool testnet; + bool enable_pusher; + public: page(MicroCore* _mcore, Blockchain* _core_storage, - string _deamon_url, string _lmdb2_path, bool _testnet) + string _deamon_url, string _lmdb2_path, + bool _testnet, bool _enable_pusher) : mcore {_mcore}, core_storage {_core_storage}, rpc {_deamon_url}, server_timestamp {std::time(nullptr)}, lmdb2_path {_lmdb2_path}, - testnet {_testnet} + testnet {_testnet}, + enable_pusher {_enable_pusher} { css_styles = xmreg::read(TMPL_CSS_STYLES); } @@ -1960,6 +1964,18 @@ public: string rpc_error_msg; + if (this->enable_pusher == false) + { + string error_msg = fmt::format( + "Pushing signed transactions is disabled. " + "Run explorer with --enable-pusher flag to enable it.\n"); + + context["has_error"] = true; + context["error_msg"] = error_msg; + + break; + } + if (!rpc.commit_tx(ptx, rpc_error_msg)) { string error_msg = fmt::format(