Support for stagenet

This commit is contained in:
stoffu 2018-03-05 11:13:29 +09:00
parent 605c6caf28
commit 2d7db18dde
No known key found for this signature in database
GPG key ID: 41DAB8343A9EC012
14 changed files with 141 additions and 59 deletions

View file

@ -50,10 +50,12 @@ main(int ac, const char* av[])
auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file"); auto ssl_key_file_opt = opts.get_option<string>("ssl-key-file");
auto no_blocks_on_index_opt = opts.get_option<string>("no-blocks-on-index"); auto no_blocks_on_index_opt = opts.get_option<string>("no-blocks-on-index");
auto testnet_url = opts.get_option<string>("testnet-url"); auto testnet_url = opts.get_option<string>("testnet-url");
auto stagenet_url = opts.get_option<string>("stagenet-url");
auto mainnet_url = opts.get_option<string>("mainnet-url"); auto mainnet_url = opts.get_option<string>("mainnet-url");
auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout"); auto mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time"); auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
auto testnet_opt = opts.get_option<bool>("testnet"); auto testnet_opt = opts.get_option<bool>("testnet");
auto stagenet_opt = opts.get_option<bool>("stagenet");
auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker"); auto enable_key_image_checker_opt = opts.get_option<bool>("enable-key-image-checker");
auto enable_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker"); auto enable_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker");
auto enable_autorefresh_option_opt = opts.get_option<bool>("enable-autorefresh-option"); auto enable_autorefresh_option_opt = opts.get_option<bool>("enable-autorefresh-option");
@ -69,6 +71,16 @@ main(int ac, const char* av[])
bool testnet {*testnet_opt}; bool testnet {*testnet_opt};
bool stagenet {*stagenet_opt};
if (testnet && stagenet)
{
cerr << "testnet and stagenet cannot be specified at the same time!" << endl;
return EXIT_FAILURE;
}
const cryptonote::network_type nettype = testnet ?
cryptonote::network_type::TESTNET : stagenet ?
cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
bool enable_pusher {*enable_pusher_opt}; bool enable_pusher {*enable_pusher_opt};
bool enable_js {*enable_js_opt}; bool enable_js {*enable_js_opt};
bool enable_key_image_checker {*enable_key_image_checker_opt}; bool enable_key_image_checker {*enable_key_image_checker_opt};
@ -128,7 +140,7 @@ main(int ac, const char* av[])
// get blockchain path // get blockchain path
path blockchain_path; path blockchain_path;
if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, testnet)) if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, nettype))
{ {
cerr << "Error getting blockchain path." << endl; cerr << "Error getting blockchain path." << endl;
return EXIT_FAILURE; return EXIT_FAILURE;
@ -154,6 +166,8 @@ main(int ac, const char* av[])
if (testnet && deamon_url == "http:://127.0.0.1:18081") if (testnet && deamon_url == "http:://127.0.0.1:18081")
deamon_url = "http:://127.0.0.1:28081"; deamon_url = "http:://127.0.0.1:28081";
if (stagenet && deamon_url == "http:://127.0.0.1:18081")
deamon_url = "http:://127.0.0.1:38081";
uint64_t mempool_info_timeout {5000}; uint64_t mempool_info_timeout {5000};
@ -187,8 +201,8 @@ main(int ac, const char* av[])
xmreg::CurrentBlockchainStatus::blockchain_path xmreg::CurrentBlockchainStatus::blockchain_path
= blockchain_path; = blockchain_path;
xmreg::CurrentBlockchainStatus::testnet xmreg::CurrentBlockchainStatus::nettype
= testnet; = nettype;
xmreg::CurrentBlockchainStatus::deamon_url xmreg::CurrentBlockchainStatus::deamon_url
= deamon_url; = deamon_url;
xmreg::CurrentBlockchainStatus::set_blockchain_variables( xmreg::CurrentBlockchainStatus::set_blockchain_variables(
@ -204,8 +218,8 @@ main(int ac, const char* av[])
xmreg::MempoolStatus::blockchain_path xmreg::MempoolStatus::blockchain_path
= blockchain_path; = blockchain_path;
xmreg::MempoolStatus::testnet xmreg::MempoolStatus::nettype
= testnet; = nettype;
xmreg::MempoolStatus::deamon_url xmreg::MempoolStatus::deamon_url
= deamon_url; = deamon_url;
xmreg::MempoolStatus::set_blockchain_variables( xmreg::MempoolStatus::set_blockchain_variables(
@ -236,7 +250,7 @@ main(int ac, const char* av[])
xmreg::page xmrblocks(&mcore, xmreg::page xmrblocks(&mcore,
core_storage, core_storage,
deamon_url, deamon_url,
testnet, nettype,
enable_pusher, enable_pusher,
enable_js, enable_js,
enable_key_image_checker, enable_key_image_checker,
@ -249,6 +263,7 @@ main(int ac, const char* av[])
no_blocks_on_index, no_blocks_on_index,
mempool_info_timeout, mempool_info_timeout,
*testnet_url, *testnet_url,
*stagenet_url,
*mainnet_url); *mainnet_url);
// crow instance // crow instance

View file

@ -25,6 +25,8 @@ namespace xmreg
"produce help message") "produce help message")
("testnet,t", value<bool>()->default_value(false)->implicit_value(true), ("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
"use testnet blockchain") "use testnet blockchain")
("stagenet,s", value<bool>()->default_value(false)->implicit_value(true),
"use stagenet blockchain")
("enable-pusher", value<bool>()->default_value(false)->implicit_value(true), ("enable-pusher", value<bool>()->default_value(false)->implicit_value(true),
"enable signed transaction pusher") "enable signed transaction pusher")
("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true), ("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true),
@ -50,9 +52,11 @@ namespace xmreg
("port,p", value<string>()->default_value("8081"), ("port,p", value<string>()->default_value("8081"),
"default explorer port") "default explorer port")
("testnet-url", value<string>()->default_value(""), ("testnet-url", value<string>()->default_value(""),
"you can specify testnet url, if you run it on mainnet. link will show on front page to testnet explorer") "you can specify testnet url, if you run it on mainnet or stagenet. link will show on front page to testnet explorer")
("stagenet-url", value<string>()->default_value(""),
"you can specify stagenet url, if you run it on mainnet or testnet. link will show on front page to stagenet explorer")
("mainnet-url", value<string>()->default_value(""), ("mainnet-url", value<string>()->default_value(""),
"you can specify mainnet url, if you run it on testnet. link will show on front page to mainnet explorer") "you can specify mainnet url, if you run it on testnet or stagenet. link will show on front page to mainnet explorer")
("no-blocks-on-index", value<string>()->default_value("10"), ("no-blocks-on-index", value<string>()->default_value("10"),
"number of last blocks to be shown on index page") "number of last blocks to be shown on index page")
("mempool-info-timeout", value<string>()->default_value("5000"), ("mempool-info-timeout", value<string>()->default_value("5000"),

View file

@ -299,7 +299,7 @@ CurrentBlockchainStatus::is_thread_running()
bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"}; bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
bool CurrentBlockchainStatus::testnet {false}; cryptonote::network_type CurrentBlockchainStatus::nettype {cryptonote::network_type::MAINNET};
string CurrentBlockchainStatus::output_file {"emission_amount.txt"}; string CurrentBlockchainStatus::output_file {"emission_amount.txt"};

View file

@ -47,7 +47,7 @@ struct CurrentBlockchainStatus
static bf::path blockchain_path; static bf::path blockchain_path;
static bool testnet; static cryptonote::network_type nettype;
static string output_file; static string output_file;

View file

@ -253,7 +253,8 @@ MempoolStatus::read_network_info()
local_copy.outgoing_connections_count = rpc_network_info.outgoing_connections_count; local_copy.outgoing_connections_count = rpc_network_info.outgoing_connections_count;
local_copy.incoming_connections_count = rpc_network_info.incoming_connections_count; local_copy.incoming_connections_count = rpc_network_info.incoming_connections_count;
local_copy.white_peerlist_size = rpc_network_info.white_peerlist_size; local_copy.white_peerlist_size = rpc_network_info.white_peerlist_size;
local_copy.testnet = rpc_network_info.testnet; local_copy.nettype = rpc_network_info.testnet ? cryptonote::network_type::TESTNET :
rpc_network_info.stagenet ? cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty; local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty;
local_copy.block_size_limit = rpc_network_info.block_size_limit; local_copy.block_size_limit = rpc_network_info.block_size_limit;
local_copy.start_time = rpc_network_info.start_time; local_copy.start_time = rpc_network_info.start_time;
@ -297,7 +298,7 @@ MempoolStatus::is_thread_running()
bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"}; bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
string MempoolStatus::deamon_url {"http:://127.0.0.1:18081"}; string MempoolStatus::deamon_url {"http:://127.0.0.1:18081"};
bool MempoolStatus::testnet {false}; cryptonote::network_type MempoolStatus::nettype {cryptonote::network_type::MAINNET};
atomic<bool> MempoolStatus::is_running {false}; atomic<bool> MempoolStatus::is_running {false};
boost::thread MempoolStatus::m_thread; boost::thread MempoolStatus::m_thread;
Blockchain* MempoolStatus::core_storage {nullptr}; Blockchain* MempoolStatus::core_storage {nullptr};

View file

@ -66,7 +66,7 @@ struct MempoolStatus
uint64_t incoming_connections_count {0}; uint64_t incoming_connections_count {0};
uint64_t white_peerlist_size {0}; uint64_t white_peerlist_size {0};
uint64_t grey_peerlist_size {0}; uint64_t grey_peerlist_size {0};
bool testnet {false}; cryptonote::network_type nettype {cryptonote::network_type::MAINNET};
crypto::hash top_block_hash; crypto::hash top_block_hash;
uint64_t cumulative_difficulty {0}; uint64_t cumulative_difficulty {0};
uint64_t block_size_limit {0}; uint64_t block_size_limit {0};
@ -119,7 +119,7 @@ struct MempoolStatus
static bf::path blockchain_path; static bf::path blockchain_path;
static string deamon_url; static string deamon_url;
static bool testnet; static cryptonote::network_type nettype;
// make object for accessing the blockchain here // make object for accessing the blockchain here
static MicroCore* mcore; static MicroCore* mcore;

View file

@ -88,7 +88,7 @@ MicroCore::init(const string& _blockchain_path)
// initialize Blockchain object to manage // initialize Blockchain object to manage
// the database. // the database.
return m_blockchain_storage.init(db, m_hardfork, false); return m_blockchain_storage.init(db, m_hardfork, network_type::MAINNET);
} }
/** /**

View file

@ -274,7 +274,10 @@ namespace xmreg
atomic<time_t> server_timestamp; atomic<time_t> server_timestamp;
cryptonote::network_type nettype;
bool mainnet;
bool testnet; bool testnet;
bool stagenet;
bool enable_js; bool enable_js;
@ -296,6 +299,7 @@ namespace xmreg
uint64_t mempool_info_timeout; uint64_t mempool_info_timeout;
string testnet_url; string testnet_url;
string stagenet_url;
string mainnet_url; string mainnet_url;
string js_html_files; string js_html_files;
@ -331,7 +335,7 @@ namespace xmreg
page(MicroCore* _mcore, page(MicroCore* _mcore,
Blockchain* _core_storage, Blockchain* _core_storage,
string _deamon_url, string _deamon_url,
bool _testnet, cryptonote::network_type _nettype,
bool _enable_pusher, bool _enable_pusher,
bool _enable_js, bool _enable_js,
bool _enable_key_image_checker, bool _enable_key_image_checker,
@ -344,12 +348,13 @@ namespace xmreg
uint64_t _no_blocks_on_index, uint64_t _no_blocks_on_index,
uint64_t _mempool_info_timeout, uint64_t _mempool_info_timeout,
string _testnet_url, string _testnet_url,
string _stagenet_url,
string _mainnet_url) string _mainnet_url)
: mcore {_mcore}, : mcore {_mcore},
core_storage {_core_storage}, core_storage {_core_storage},
rpc {_deamon_url}, rpc {_deamon_url},
server_timestamp {std::time(nullptr)}, server_timestamp {std::time(nullptr)},
testnet {_testnet}, nettype {_nettype},
enable_pusher {_enable_pusher}, enable_pusher {_enable_pusher},
enable_js {_enable_js}, enable_js {_enable_js},
enable_key_image_checker {_enable_key_image_checker}, enable_key_image_checker {_enable_key_image_checker},
@ -362,10 +367,15 @@ namespace xmreg
no_blocks_on_index {_no_blocks_on_index}, no_blocks_on_index {_no_blocks_on_index},
mempool_info_timeout {_mempool_info_timeout}, mempool_info_timeout {_mempool_info_timeout},
testnet_url {_testnet_url}, testnet_url {_testnet_url},
stagenet_url {_stagenet_url},
mainnet_url {_mainnet_url}, mainnet_url {_mainnet_url},
block_tx_cache(200), block_tx_cache(200),
tx_context_cache(1000) tx_context_cache(1000)
{ {
mainnet = nettype == cryptonote::network_type::MAINNET;
testnet = nettype == cryptonote::network_type::TESTNET;
stagenet = nettype == cryptonote::network_type::STAGENET;
no_of_mempool_tx_of_frontpage = 25; no_of_mempool_tx_of_frontpage = 25;
@ -419,6 +429,16 @@ namespace xmreg
"testnet: true"); "testnet: true");
} }
// the same idea as above for the stagenet
if (stagenet)
{
template_file["config.js"] = std::regex_replace(
template_file["config.js"],
std::regex("stagenet: false"),
"stagenet: true");
}
template_file["all_in_one.js"] = template_file["jquery.min.js"] + template_file["all_in_one.js"] = template_file["jquery.min.js"] +
template_file["crc32.js"] + template_file["crc32.js"] +
template_file["biginteger.js"] + template_file["biginteger.js"] +
@ -491,7 +511,9 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"testnet_url" , testnet_url}, {"testnet_url" , testnet_url},
{"stagenet_url" , stagenet_url},
{"mainnet_url" , mainnet_url}, {"mainnet_url" , mainnet_url},
{"refresh" , refresh_page}, {"refresh" , refresh_page},
{"height" , height}, {"height" , height},
@ -784,7 +806,7 @@ namespace xmreg
// perapre network info mstch::map for the front page // perapre network info mstch::map for the front page
string hash_rate; string hash_rate;
if (testnet) if (testnet || stagenet)
{ {
hash_rate = std::to_string(current_network_info.hash_rate) + " H/s"; hash_rate = std::to_string(current_network_info.hash_rate) + " H/s";
} }
@ -1002,6 +1024,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"blocks" , mstch::array()} {"blocks" , mstch::array()}
}; };
@ -1145,6 +1168,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"blk_hash" , blk_hash_str}, {"blk_hash" , blk_hash_str},
{"blk_height" , _blk_height}, {"blk_height" , _blk_height},
{"blk_timestamp" , blk_timestamp}, {"blk_timestamp" , blk_timestamp},
@ -1471,6 +1495,7 @@ namespace xmreg
mstch::map context { mstch::map context {
{"testnet" , this->testnet}, {"testnet" , this->testnet},
{"stagenet" , this->stagenet},
{"show_cache_times" , show_cache_times}, {"show_cache_times" , show_cache_times},
{"txs" , mstch::array{}} {"txs" , mstch::array{}}
}; };
@ -1535,7 +1560,7 @@ namespace xmreg
// parse string representing given monero address // parse string representing given monero address
cryptonote::address_parse_info address_info; cryptonote::address_parse_info address_info;
if (!xmreg::parse_str_address(xmr_address_str, address_info, testnet)) if (!xmreg::parse_str_address(xmr_address_str, address_info, nettype))
{ {
cerr << "Cant parse string address: " << xmr_address_str << endl; cerr << "Cant parse string address: " << xmr_address_str << endl;
return string("Cant parse xmr address: " + xmr_address_str); return string("Cant parse xmr address: " + xmr_address_str);
@ -1706,6 +1731,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)}, {"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)},
{"xmr_address" , xmr_address_str}, {"xmr_address" , xmr_address_str},
@ -2280,7 +2306,8 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet} {"testnet" , testnet},
{"stagenet" , stagenet}
}; };
add_css_style(context); add_css_style(context);
@ -2312,6 +2339,7 @@ namespace xmreg
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"unsigned_tx_given" , unsigned_tx_given}, {"unsigned_tx_given" , unsigned_tx_given},
{"have_raw_tx" , true}, {"have_raw_tx" , true},
{"has_error" , false}, {"has_error" , false},
@ -2389,7 +2417,7 @@ namespace xmreg
{ {
mstch::map dest_info { mstch::map dest_info {
{"dest_address" , get_account_address_as_str( {"dest_address" , get_account_address_as_str(
testnet, a_dest.is_subaddress, a_dest.addr)}, nettype, a_dest.is_subaddress, a_dest.addr)},
{"dest_amount" , xmreg::xmr_amount_to_str(a_dest.amount)} {"dest_amount" , xmreg::xmr_amount_to_str(a_dest.amount)}
}; };
@ -2733,7 +2761,7 @@ namespace xmreg
destination_addresses.push_back( destination_addresses.push_back(
mstch::map { mstch::map {
{"dest_address" , get_account_address_as_str( {"dest_address" , get_account_address_as_str(
testnet, a_dest.is_subaddress, a_dest.addr)}, nettype, a_dest.is_subaddress, a_dest.addr)},
{"dest_amount" , xmreg::xmr_amount_to_str(a_dest.amount)}, {"dest_amount" , xmreg::xmr_amount_to_str(a_dest.amount)},
{"is_this_change" , false} {"is_this_change" , false}
} }
@ -2750,7 +2778,7 @@ namespace xmreg
destination_addresses.push_back( destination_addresses.push_back(
mstch::map { mstch::map {
{"dest_address" , get_account_address_as_str( {"dest_address" , get_account_address_as_str(
testnet, ptx.construction_data.change_dts.is_subaddress, ptx.construction_data.change_dts.addr)}, nettype, ptx.construction_data.change_dts.is_subaddress, ptx.construction_data.change_dts.addr)},
{"dest_amount" , {"dest_amount" ,
xmreg::xmr_amount_to_str(ptx.construction_data.change_dts.amount)}, xmreg::xmr_amount_to_str(ptx.construction_data.change_dts.amount)},
{"is_this_change" , true} {"is_this_change" , true}
@ -2934,6 +2962,7 @@ namespace xmreg
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"have_raw_tx" , true}, {"have_raw_tx" , true},
{"has_error" , false}, {"has_error" , false},
{"error_msg" , string {}}, {"error_msg" , string {}},
@ -3137,6 +3166,7 @@ namespace xmreg
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
}; };
add_css_style(context); add_css_style(context);
@ -3150,7 +3180,8 @@ namespace xmreg
{ {
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet} {"testnet" , testnet},
{"stagenet" , stagenet}
}; };
add_css_style(context); add_css_style(context);
@ -3174,6 +3205,7 @@ namespace xmreg
// initalize page template context map // initalize page template context map
mstch::map context{ mstch::map context{
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"has_error" , false}, {"has_error" , false},
{"error_msg" , string{}}, {"error_msg" , string{}},
}; };
@ -3262,7 +3294,7 @@ namespace xmreg
context.insert({"address" , REMOVE_HASH_BRAKETS( context.insert({"address" , REMOVE_HASH_BRAKETS(
xmreg::print_address(address_info, testnet))}); xmreg::print_address(address_info, nettype))});
context.insert({"viewkey" , REMOVE_HASH_BRAKETS( context.insert({"viewkey" , REMOVE_HASH_BRAKETS(
fmt::format("{:s}", prv_view_key))}); fmt::format("{:s}", prv_view_key))});
context.insert({"has_total_xmr" , false}); context.insert({"has_total_xmr" , false});
@ -3291,7 +3323,7 @@ namespace xmreg
{"key_image" , pod_to_hex(key_image)}, {"key_image" , pod_to_hex(key_image)},
{"signature" , fmt::format("{:s}", signature)}, {"signature" , fmt::format("{:s}", signature)},
{"address" , xmreg::print_address( {"address" , xmreg::print_address(
address_info, testnet)}, address_info, nettype)},
{"is_spent" , core_storage->have_tx_keyimg_as_spent(key_image)}, {"is_spent" , core_storage->have_tx_keyimg_as_spent(key_image)},
{"tx_hash" , string{}} {"tx_hash" , string{}}
}; };
@ -3319,6 +3351,7 @@ namespace xmreg
// initalize page template context map // initalize page template context map
mstch::map context{ mstch::map context{
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"has_error" , false}, {"has_error" , false},
{"error_msg" , string{}} {"error_msg" , string{}}
}; };
@ -3395,7 +3428,7 @@ namespace xmreg
address_parse_info address_info {*xmr_address, false}; address_parse_info address_info {*xmr_address, false};
context.insert({"address" , REMOVE_HASH_BRAKETS( context.insert({"address" , REMOVE_HASH_BRAKETS(
xmreg::print_address(address_info, testnet))}); xmreg::print_address(address_info, nettype))});
context.insert({"viewkey" , REMOVE_HASH_BRAKETS( context.insert({"viewkey" , REMOVE_HASH_BRAKETS(
fmt::format("{:s}", prv_view_key))}); fmt::format("{:s}", prv_view_key))});
context.insert({"has_total_xmr" , false}); context.insert({"has_total_xmr" , false});
@ -3612,19 +3645,21 @@ namespace xmreg
// parse string representing given monero address // parse string representing given monero address
address_parse_info address_info; address_parse_info address_info;
bool testnet_addr {false}; cryptonote::network_type nettype_addr {cryptonote::network_type::MAINNET};
if (search_text[0] == '9' || search_text[0] == 'A' || search_text[0] == 'B') if (search_text[0] == '9' || search_text[0] == 'A' || search_text[0] == 'B')
testnet_addr = true; nettype_addr = cryptonote::network_type::TESTNET;
if (search_text[0] == '5' || search_text[0] == '7')
nettype_addr = cryptonote::network_type::STAGENET;
if (!xmreg::parse_str_address(search_text, address_info, testnet_addr)) if (!xmreg::parse_str_address(search_text, address_info, nettype_addr))
{ {
cerr << "Cant parse string address: " << search_text << endl; cerr << "Cant parse string address: " << search_text << endl;
return string("Cant parse address (probably incorrect format): ") return string("Cant parse address (probably incorrect format): ")
+ search_text; + search_text;
} }
return show_address_details(address_info, testnet_addr); return show_address_details(address_info, nettype_addr);
} }
// check if integrated monero address is given based on its length // check if integrated monero address is given based on its length
@ -3636,7 +3671,7 @@ namespace xmreg
address_parse_info address_info; address_parse_info address_info;
if (!get_account_address_from_str(address_info, testnet, search_text)) if (!get_account_address_from_str(address_info, nettype, search_text))
{ {
cerr << "Cant parse string integerated address: " << search_text << endl; cerr << "Cant parse string integerated address: " << search_text << endl;
return string("Cant parse address (probably incorrect format): ") return string("Cant parse address (probably incorrect format): ")
@ -3645,7 +3680,7 @@ namespace xmreg
return show_integrated_address_details(address_info, return show_integrated_address_details(address_info,
address_info.payment_id, address_info.payment_id,
testnet); nettype);
} }
// all_possible_tx_hashes was field using custom lmdb database // all_possible_tx_hashes was field using custom lmdb database
@ -3659,10 +3694,10 @@ namespace xmreg
} }
string string
show_address_details(const address_parse_info& address_info, bool testnet = false) show_address_details(const address_parse_info& address_info, cryptonote::network_type nettype = cryptonote::network_type::MAINNET)
{ {
string address_str = xmreg::print_address(address_info, testnet); string address_str = xmreg::print_address(address_info, nettype);
string pub_viewkey_str = fmt::format("{:s}", address_info.address.m_view_public_key); string pub_viewkey_str = fmt::format("{:s}", address_info.address.m_view_public_key);
string pub_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key); string pub_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key);
@ -3671,7 +3706,8 @@ namespace xmreg
{"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)}, {"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)},
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)}, {"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"is_integrated_addr" , false}, {"is_integrated_addr" , false},
{"testnet" , testnet} {"testnet" , testnet},
{"stagenet" , stagenet},
}; };
add_css_style(context); add_css_style(context);
@ -3684,10 +3720,10 @@ namespace xmreg
string string
show_integrated_address_details(const address_parse_info& address_info, show_integrated_address_details(const address_parse_info& address_info,
const crypto::hash8& encrypted_payment_id, const crypto::hash8& encrypted_payment_id,
bool testnet = false) cryptonote::network_type nettype = cryptonote::network_type::MAINNET)
{ {
string address_str = xmreg::print_address(address_info, testnet); string address_str = xmreg::print_address(address_info, nettype);
string pub_viewkey_str = fmt::format("{:s}", address_info.address.m_view_public_key); string pub_viewkey_str = fmt::format("{:s}", address_info.address.m_view_public_key);
string pub_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key); string pub_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key);
string enc_payment_id_str = fmt::format("{:s}", encrypted_payment_id); string enc_payment_id_str = fmt::format("{:s}", encrypted_payment_id);
@ -3698,7 +3734,8 @@ namespace xmreg
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)}, {"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)}, {"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)},
{"is_integrated_addr" , true}, {"is_integrated_addr" , true},
{"testnet" , testnet} {"testnet" , testnet},
{"stagenet" , stagenet},
}; };
add_css_style(context); add_css_style(context);
@ -3789,6 +3826,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"search_text" , search_text}, {"search_text" , search_text},
{"no_results" , true}, {"no_results" , true},
{"to_many_results" , false} {"to_many_results" , false}
@ -4753,7 +4791,7 @@ namespace xmreg
// parse string representing given monero address // parse string representing given monero address
address_parse_info address_info; address_parse_info address_info;
if (!xmreg::parse_str_address(address_str, address_info, testnet)) if (!xmreg::parse_str_address(address_str, address_info, nettype))
{ {
j_response["status"] = "error"; j_response["status"] = "error";
j_response["message"] = "Cant parse monero address: " + address_str; j_response["message"] = "Cant parse monero address: " + address_str;
@ -4958,7 +4996,7 @@ namespace xmreg
// parse string representing given monero address // parse string representing given monero address
address_parse_info address_info; address_parse_info address_info;
if (!xmreg::parse_str_address(address_str, address_info, testnet)) if (!xmreg::parse_str_address(address_str, address_info, nettype))
{ {
j_response["status"] = "error"; j_response["status"] = "error";
j_response["message"] = "Cant parse monero address: " + address_str; j_response["message"] = "Cant parse monero address: " + address_str;
@ -5529,6 +5567,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"stagenet" , stagenet},
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , string{}}, {"tx_prefix_hash" , string{}},
{"tx_pub_key" , pod_to_hex(txd.pk)}, {"tx_pub_key" , pod_to_hex(txd.pk)},
@ -6176,7 +6215,8 @@ namespace xmreg
{"incoming_connections_count", local_copy_network_info.incoming_connections_count}, {"incoming_connections_count", local_copy_network_info.incoming_connections_count},
{"white_peerlist_size" , local_copy_network_info.white_peerlist_size}, {"white_peerlist_size" , local_copy_network_info.white_peerlist_size},
{"grey_peerlist_size" , local_copy_network_info.grey_peerlist_size}, {"grey_peerlist_size" , local_copy_network_info.grey_peerlist_size},
{"testnet" , local_copy_network_info.testnet}, {"testnet" , local_copy_network_info.nettype == cryptonote::network_type::TESTNET},
{"stagenet" , local_copy_network_info.nettype == cryptonote::network_type::STAGENET},
{"top_block_hash" , pod_to_hex(local_copy_network_info.top_block_hash)}, {"top_block_hash" , pod_to_hex(local_copy_network_info.top_block_hash)},
{"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty}, {"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty},
{"block_size_limit" , local_copy_network_info.block_size_limit}, {"block_size_limit" , local_copy_network_info.block_size_limit},

View file

@ -5,11 +5,14 @@
<br/> <br/>
{{#testnet}} {{#testnet}}
<H4 style="margin:5px">Testnet address: Yes</H4> <H4 style="margin:5px">Network type: Testnet</H4>
{{/testnet}}
{{^testnet}}
<H4 style="margin:5px">Testnet address: No</H4>
{{/testnet}} {{/testnet}}
{{#stagenet}}
<H4 style="margin:5px">Network type: Stagenet</H4>
{{/stagenet}}
{{^testnet}}{{^stagenet}}
<H4 style="margin:5px">Network type: Mainnet</H4>
{{/stagenet}}{{/testnet}}
<br/> <br/>
<H4 style="margin:5px">Associated public keys</H4> <H4 style="margin:5px">Associated public keys</H4>

View file

@ -24,12 +24,18 @@
{{#testnet_url}} {{#testnet_url}}
| <a href="{{testnet_url}}">Go to testnet explorer</a> | <a href="{{testnet_url}}">Go to testnet explorer</a>
{{/testnet_url}} {{/testnet_url}}
{{#stagenet_url}}
| <a href="{{stagenet_url}}">Go to stagenet explorer</a>
{{/stagenet_url}}
{{#mainnet_url}} {{#mainnet_url}}
| <a href="{{mainnet_url}}">Go to mainnet explorer</a> | <a href="{{mainnet_url}}">Go to mainnet explorer</a>
{{/mainnet_url}} {{/mainnet_url}}
{{#testnet}} {{#testnet}}
| This is <span style="color:#ff6b62">testnet</span> blockchian | This is <span style="color:#ff6b62">testnet</span> blockchian
{{/testnet}} {{/testnet}}
{{#stagenet}}
| This is <span style="color:#ff6b62">stagenet</span> blockchian
{{/stagenet}}
</h3> </h3>

View file

@ -56,6 +56,13 @@ var cnUtil = (function(initConfig) {
CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixTestnet; CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixTestnet;
} }
if (config.stagenet === true)
{
CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = config.addressPrefixStagenet;
CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = config.integratedAddressPrefixStagenet;
CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = config.subAddressPrefixStagenet;
}
var UINT64_MAX = new JSBigInt(2).pow(64); var UINT64_MAX = new JSBigInt(2).pow(64);
var CURRENT_TX_VERSION = 2; var CURRENT_TX_VERSION = 2;
var OLD_TX_VERSION = 1; var OLD_TX_VERSION = 1;

View file

@ -1,5 +1,6 @@
var config = { var config = {
testnet: false, // this is adjusted page.h if needed. dont need to change manually testnet: false, // this is adjusted page.h if needed. dont need to change manually
stagenet: false, // this is adjusted page.h if needed. dont need to change manually
coinUnitPlaces: 12, coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
@ -13,6 +14,9 @@ var config = {
addressPrefixTestnet: 53, addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54, integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63, subAddressPrefixTestnet: 63,
addressPrefixStagenet: 24,
integratedAddressPrefixStagenet: 25,
subAddressPrefixStagenet: 36,
feePerKB: new JSBigInt('2000000000'),//20^10 - for testnet its not used, as fee is dynamic. feePerKB: new JSBigInt('2000000000'),//20^10 - for testnet its not used, as fee is dynamic.
dustThreshold: new JSBigInt('1000000000'),//10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold dustThreshold: new JSBigInt('1000000000'),//10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold
txChargeRatio: 0.5, txChargeRatio: 0.5,

View file

@ -78,10 +78,10 @@ get_tx_pub_key_from_str_hash(Blockchain& core_storage, const string& hash_str, t
bool bool
parse_str_address(const string& address_str, parse_str_address(const string& address_str,
address_parse_info& address_info, address_parse_info& address_info,
bool testnet) cryptonote::network_type nettype)
{ {
if (!get_account_address_from_str(address_info, testnet, address_str)) if (!get_account_address_from_str(address_info, nettype, address_str))
{ {
cerr << "Error getting address: " << address_str << endl; cerr << "Error getting address: " << address_str << endl;
return false; return false;
@ -95,10 +95,10 @@ parse_str_address(const string& address_str,
* Return string representation of monero address * Return string representation of monero address
*/ */
string string
print_address(const address_parse_info& address_info, bool testnet) print_address(const address_parse_info& address_info, cryptonote::network_type nettype)
{ {
return "<" + get_account_address_as_str( return "<" + get_account_address_as_str(
testnet, address_info.is_subaddress, address_info.address) nettype, address_info.is_subaddress, address_info.address)
+ ">"; + ">";
} }
@ -180,7 +180,7 @@ timestamp_to_str_gm(time_t timestamp, const char* format)
ostream& ostream&
operator<< (ostream& os, const address_parse_info& addr_info) operator<< (ostream& os, const address_parse_info& addr_info)
{ {
os << get_account_address_as_str(false, addr_info.is_subaddress, addr_info.address); os << get_account_address_as_str(network_type::MAINNET, addr_info.is_subaddress, addr_info.address);
return os; return os;
} }
@ -237,14 +237,16 @@ generate_key_image(const crypto::key_derivation& derivation,
string string
get_default_lmdb_folder(bool testnet) get_default_lmdb_folder(cryptonote::network_type nettype)
{ {
// default path to monero folder // default path to monero folder
// on linux this is /home/<username>/.bitmonero // on linux this is /home/<username>/.bitmonero
string default_monero_dir = tools::get_default_data_dir(); string default_monero_dir = tools::get_default_data_dir();
if (testnet) if (nettype == cryptonote::network_type::TESTNET)
default_monero_dir += "/testnet"; default_monero_dir += "/testnet";
if (nettype == cryptonote::network_type::STAGENET)
default_monero_dir += "/stagenet";
// the default folder of the lmdb blockchain database // the default folder of the lmdb blockchain database
@ -261,10 +263,10 @@ get_default_lmdb_folder(bool testnet)
bool bool
get_blockchain_path(const boost::optional<string>& bc_path, get_blockchain_path(const boost::optional<string>& bc_path,
bf::path& blockchain_path, bf::path& blockchain_path,
bool testnet) cryptonote::network_type nettype)
{ {
// the default folder of the lmdb blockchain database // the default folder of the lmdb blockchain database
string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet); string default_lmdb_dir = xmreg::get_default_lmdb_folder(nettype);
blockchain_path = bc_path blockchain_path = bc_path
? bf::path(*bc_path) ? bf::path(*bc_path)

View file

@ -101,14 +101,14 @@ get_tx_pub_key_from_str_hash(Blockchain& core_storage,
bool bool
parse_str_address(const string& address_str, parse_str_address(const string& address_str,
address_parse_info& address_info, address_parse_info& address_info,
bool testnet = false); cryptonote::network_type nettype = cryptonote::network_type::MAINNET);
inline bool inline bool
is_separator(char c); is_separator(char c);
string string
print_address(const address_parse_info& address, print_address(const address_parse_info& address,
bool testnet = false); cryptonote::network_type nettype = cryptonote::network_type::MAINNET);
string string
print_sig (const signature& sig); print_sig (const signature& sig);
@ -127,7 +127,7 @@ operator<< (ostream& os, const address_parse_info& addr_info);
string string
get_default_lmdb_folder(bool testnet = false); get_default_lmdb_folder(cryptonote::network_type nettype = cryptonote::network_type::MAINNET);
bool bool
generate_key_image(const crypto::key_derivation& derivation, generate_key_image(const crypto::key_derivation& derivation,
@ -139,7 +139,7 @@ generate_key_image(const crypto::key_derivation& derivation,
bool bool
get_blockchain_path(const boost::optional<string>& bc_path, get_blockchain_path(const boost::optional<string>& bc_path,
bf::path& blockchain_path, bf::path& blockchain_path,
bool testnet = false); cryptonote::network_type nettype = cryptonote::network_type::MAINNET);
uint64_t uint64_t
sum_money_in_outputs(const transaction& tx); sum_money_in_outputs(const transaction& tx);