diff --git a/main.cpp b/main.cpp index f4185c5..8e81c94 100644 --- a/main.cpp +++ b/main.cpp @@ -24,7 +24,8 @@ int main(int ac, const char* av[]) { // get command line options xmreg::CmdLineOptions opts {ac, av}; - auto help_opt = opts.get_option("help"); + auto help_opt = opts.get_option("help"); + auto testnet_opt = opts.get_option("testnet"); // if help was chosen, display help text and finish if (*help_opt) @@ -32,6 +33,8 @@ int main(int ac, const char* av[]) { return EXIT_SUCCESS; } + bool testnet {*testnet_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"); @@ -43,12 +46,14 @@ int main(int ac, const char* av[]) { // get blockchain path path blockchain_path; - if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path)) + if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, testnet)) { cerr << "Error getting blockchain path." << endl; return EXIT_FAILURE; } + cout << blockchain_path << endl; + // enable basic monero log output xmreg::enable_monero_log(); @@ -94,10 +99,18 @@ int main(int ac, const char* av[]) { custom_db_path_str = xmreg::remove_trailing_path_separator(custom_db_path_str); + + string deamon_url {*deamon_url_opt}; + + if (testnet) + deamon_url = "http:://127.0.0.1:28081"; + // create instance of page class which // contains logic for the website xmreg::page xmrblocks(&mcore, core_storage, - *deamon_url_opt, custom_db_path_str); + deamon_url, + custom_db_path_str, + testnet); // crow instance crow::SimpleApp app; diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index d6af3fc..291adbb 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -23,6 +23,8 @@ namespace xmreg desc.add_options() ("help,h", value()->default_value(false)->implicit_value(true), "produce help message") + ("testnet,t", value()->default_value(false)->implicit_value(true), + "use testnet blockchain") ("port,p", value()->default_value("8081"), "default port") ("bc-path,b", value(), diff --git a/src/page.h b/src/page.h index 04f39d3..0329d01 100644 --- a/src/page.h +++ b/src/page.h @@ -234,16 +234,19 @@ namespace xmreg { string lmdb2_path; + bool testnet; + public: page(MicroCore* _mcore, Blockchain* _core_storage, - string _deamon_url, string _lmdb2_path) + string _deamon_url, string _lmdb2_path, bool _testnet) : mcore {_mcore}, core_storage {_core_storage}, rpc {_deamon_url}, server_timestamp {std::time(nullptr)}, - lmdb2_path {_lmdb2_path} + lmdb2_path {_lmdb2_path}, + testnet {_testnet} { } @@ -972,6 +975,7 @@ namespace xmreg { {"tx_size" , fmt::format("{:0.4f}", static_cast(txd.size) / 1024.0)}, {"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))}, + {"tx_version" , fmt::format("{:d}", txd.version)}, {"blk_timestamp" , blk_timestamp}, {"blk_timestamp_uint" , blk.timestamp}, {"delta_time" , age.first}, diff --git a/src/templates/tx.html b/src/templates/tx.html index b7a0c73..d65df80 100644 --- a/src/templates/tx.html +++ b/src/templates/tx.html @@ -35,6 +35,9 @@ Fee: {{tx_fee}} Tx size: {{tx_size}} kB + + Tx version: {{tx_version}} + Extra: {{extra}} diff --git a/src/tools.cpp b/src/tools.cpp index 586db04..bd26c7f 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -223,12 +223,16 @@ namespace xmreg string - get_default_lmdb_folder() + get_default_lmdb_folder(bool testnet) { // default path to monero folder // on linux this is /home//.bitmonero string default_monero_dir = tools::get_default_data_dir(); + if (testnet) + default_monero_dir += "/testnet"; + + // the default folder of the lmdb blockchain database // is therefore as follows return default_monero_dir + string("/lmdb"); @@ -241,17 +245,17 @@ namespace xmreg * If not given, provide default path */ bool - get_blockchain_path(const boost::optional& bc_path, bf::path& blockchain_path ) + get_blockchain_path(const boost::optional& bc_path, + bf::path& blockchain_path, + bool testnet) { // the default folder of the lmdb blockchain database - string default_lmdb_dir = xmreg::get_default_lmdb_folder(); + string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet); blockchain_path = bc_path ? bf::path(*bc_path) : bf::path(default_lmdb_dir); - - if (!bf::is_directory(blockchain_path)) { cerr << "Given path \"" << blockchain_path << "\" " diff --git a/src/tools.h b/src/tools.h index 0f1bb7e..b1e82c2 100644 --- a/src/tools.h +++ b/src/tools.h @@ -118,7 +118,7 @@ namespace xmreg string - get_default_lmdb_folder(); + get_default_lmdb_folder(bool testnet = false); bool generate_key_image(const crypto::key_derivation& derivation, @@ -129,7 +129,8 @@ namespace xmreg bool get_blockchain_path(const boost::optional& bc_path, - bf::path& blockchain_path); + bf::path& blockchain_path, + bool testnet = false); uint64_t sum_money_in_outputs(const transaction& tx);