moneroexamples 6 years ago
parent 605c6caf28
commit 3a055f9fbd

@ -110,15 +110,14 @@ set(LIBRARIES
blocks
lmdb
ringct
ringct_basic
device
common
mnemonics
easylogging
checkpoints
version
epee_readline
epee
readline
${Boost_LIBRARIES}
pthread
unbound
@ -127,7 +126,7 @@ set(LIBRARIES
ssl)
if(APPLE)
set(LIBRARIES ${LIBRARIES} "-framework IOKit")
set(LIBRARIES ${LIBRARIES} "-framework IOKit -framework PCSC")
else()
set(LIBRARIES ${LIBRARIES} atomic)
endif()

@ -28,7 +28,7 @@
# (c) 2014-2016 cpp-ethereum contributors.
#------------------------------------------------------------------------------
set(LIBS common;blocks;cryptonote_basic;cryptonote_core;epee_readline;
set(LIBS common;blocks;cryptonote_basic;cryptonote_core;
cryptonote_protocol;daemonizer;mnemonics;epee;lmdb;device;
blockchain_db;ringct;wallet;cncrypto;easylogging;version;checkpoints)
@ -57,11 +57,12 @@ foreach (l ${LIBS})
endforeach()
#if (EXISTS ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
# add_library(easylogging STATIC IMPORTED)
# set_property(TARGET easylogging
# PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a)
#endif()
if (EXISTS ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a)
add_library(ringct_basic STATIC IMPORTED)
set_property(TARGET ringct_basic
PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a)
endif()
message(STATUS ${MONERO_SOURCE_DIR}/build)

@ -50,10 +50,12 @@ main(int ac, const char* av[])
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 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 mempool_info_timeout_opt = opts.get_option<string>("mempool-info-timeout");
auto mempool_refresh_time_opt = opts.get_option<string>("mempool-refresh-time");
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_output_key_checker_opt = opts.get_option<bool>("enable-output-key-checker");
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 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_js {*enable_js_opt};
bool enable_key_image_checker {*enable_key_image_checker_opt};
@ -128,7 +140,7 @@ main(int ac, const char* av[])
// get 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;
return EXIT_FAILURE;
@ -154,6 +166,8 @@ main(int ac, const char* av[])
if (testnet && deamon_url == "http:://127.0.0.1:18081")
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};
@ -187,8 +201,8 @@ main(int ac, const char* av[])
xmreg::CurrentBlockchainStatus::blockchain_path
= blockchain_path;
xmreg::CurrentBlockchainStatus::testnet
= testnet;
xmreg::CurrentBlockchainStatus::nettype
= nettype;
xmreg::CurrentBlockchainStatus::deamon_url
= deamon_url;
xmreg::CurrentBlockchainStatus::set_blockchain_variables(
@ -204,8 +218,8 @@ main(int ac, const char* av[])
xmreg::MempoolStatus::blockchain_path
= blockchain_path;
xmreg::MempoolStatus::testnet
= testnet;
xmreg::MempoolStatus::nettype
= nettype;
xmreg::MempoolStatus::deamon_url
= deamon_url;
xmreg::MempoolStatus::set_blockchain_variables(
@ -236,7 +250,7 @@ main(int ac, const char* av[])
xmreg::page xmrblocks(&mcore,
core_storage,
deamon_url,
testnet,
nettype,
enable_pusher,
enable_js,
enable_key_image_checker,
@ -249,6 +263,7 @@ main(int ac, const char* av[])
no_blocks_on_index,
mempool_info_timeout,
*testnet_url,
*stagenet_url,
*mainnet_url);
// crow instance

@ -25,6 +25,8 @@ namespace xmreg
"produce help message")
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
"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 signed transaction pusher")
("enable-mixin-details", value<bool>()->default_value(false)->implicit_value(true),
@ -50,9 +52,11 @@ namespace xmreg
("port,p", value<string>()->default_value("8081"),
"default explorer port")
("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(""),
"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"),
"number of last blocks to be shown on index page")
("mempool-info-timeout", value<string>()->default_value("5000"),

@ -299,7 +299,7 @@ CurrentBlockchainStatus::is_thread_running()
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"};

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

@ -153,6 +153,12 @@ MempoolStatus::read_mempool()
const array<uint64_t, 4>& sum_data = summary_of_in_out_rct(
tx, output_pub_keys, input_key_imgs);
double tx_size = static_cast<double>(_tx_info.blob_size)/1024.0;
double payed_for_kB = XMR_AMOUNT(_tx_info.fee) / tx_size;
last_tx.receive_time = _tx_info.receive_time;
last_tx.sum_outputs = sum_data[0];
@ -162,15 +168,15 @@ MempoolStatus::read_mempool()
last_tx.mixin_no = sum_data[2];
last_tx.num_nonrct_inputs = sum_data[3];
last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false);
last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}");
last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}");
last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time);
last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false);
last_tx.payed_for_kB_str = fmt::format("{:0.3f}", payed_for_kB);
last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}");
last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}");
last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time);
last_tx.txsize = fmt::format("{:0.2f}",
static_cast<double>(_tx_info.blob_size)/1024.0);
last_tx.txsize = fmt::format("{:0.2f}", tx_size);
last_tx.pID = '-';
last_tx.pID = '-';
crypto::hash payment_id;
crypto::hash8 payment_id8;
@ -253,7 +259,8 @@ MempoolStatus::read_network_info()
local_copy.outgoing_connections_count = rpc_network_info.outgoing_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.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.block_size_limit = rpc_network_info.block_size_limit;
local_copy.start_time = rpc_network_info.start_time;
@ -297,7 +304,7 @@ MempoolStatus::is_thread_running()
bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"};
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};
boost::thread MempoolStatus::m_thread;
Blockchain* MempoolStatus::core_storage {nullptr};

@ -38,6 +38,7 @@ struct MempoolStatus
uint64_t mixin_no {0};
string fee_str;
string payed_for_kB_str;
string xmr_inputs_str;
string xmr_outputs_str;
string timestamp_str;
@ -66,7 +67,7 @@ struct MempoolStatus
uint64_t incoming_connections_count {0};
uint64_t white_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;
uint64_t cumulative_difficulty {0};
uint64_t block_size_limit {0};
@ -119,7 +120,7 @@ struct MempoolStatus
static bf::path blockchain_path;
static string deamon_url;
static bool testnet;
static cryptonote::network_type nettype;
// make object for accessing the blockchain here
static MicroCore* mcore;

@ -32,7 +32,9 @@ namespace xmreg
MicroCore::MicroCore():
m_mempool(m_blockchain_storage),
m_blockchain_storage(m_mempool)
{}
{
m_device = &hw::get_device("default");
}
/**
@ -88,7 +90,7 @@ MicroCore::init(const string& _blockchain_path)
// initialize Blockchain object to manage
// the database.
return m_blockchain_storage.init(db, m_hardfork, false);
return m_blockchain_storage.init(db, m_hardfork, network_type::MAINNET);
}
/**
@ -358,4 +360,10 @@ MicroCore::get_blkchain_path()
return blockchain_path;
}
hw::device* const
MicroCore::get_device() const
{
return m_device;
}
}

@ -31,6 +31,8 @@ namespace xmreg
tx_memory_pool m_mempool;
Blockchain m_blockchain_storage;
hw::device* m_device;
public:
MicroCore();
@ -67,6 +69,8 @@ namespace xmreg
string
get_blkchain_path();
hw::device* const
get_device() const;
virtual ~MicroCore();
};

@ -24,6 +24,7 @@
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "device/device_default.hpp"
#include "wallet/wallet2.h"

@ -175,17 +175,24 @@ namespace xmreg
string mixin_str {"N/A"};
string fee_str {"N/A"};
string fee_short_str {"N/A"};
string payed_for_kB_str {""};
const double& xmr_amount = XMR_AMOUNT(fee);
// tx size in kB
double tx_size = static_cast<double>(size)/1024.0;
if (!input_key_imgs.empty())
{
mixin_str = std::to_string(mixin_no);
fee_str = fmt::format("{:0.6f}", xmr_amount);
fee_short_str = fmt::format("{:0.3f}", xmr_amount);
double payed_for_kB = xmr_amount / tx_size;
mixin_str = std::to_string(mixin_no);
fee_str = fmt::format("{:0.6f}", xmr_amount);
fee_short_str = fmt::format("{:0.3f}", xmr_amount);
payed_for_kB_str = fmt::format("{:0.3f}", payed_for_kB);
}
const double& tx_size = static_cast<double>(size)/1024.0;
mstch::map txd_map {
{"hash" , pod_to_hex(hash)},
@ -193,6 +200,7 @@ namespace xmreg
{"pub_key" , pod_to_hex(pk)},
{"tx_fee" , fee_str},
{"tx_fee_short" , fee_short_str},
{"payed_for_kB" , payed_for_kB_str},
{"sum_inputs" , xmr_amount_to_str(xmr_inputs , "{:0.6f}")},
{"sum_outputs" , xmr_amount_to_str(xmr_outputs, "{:0.6f}")},
{"sum_inputs_short" , xmr_amount_to_str(xmr_inputs , "{:0.3f}")},
@ -274,7 +282,10 @@ namespace xmreg
atomic<time_t> server_timestamp;
cryptonote::network_type nettype;
bool mainnet;
bool testnet;
bool stagenet;
bool enable_js;
@ -296,6 +307,7 @@ namespace xmreg
uint64_t mempool_info_timeout;
string testnet_url;
string stagenet_url;
string mainnet_url;
string js_html_files;
@ -331,7 +343,7 @@ namespace xmreg
page(MicroCore* _mcore,
Blockchain* _core_storage,
string _deamon_url,
bool _testnet,
cryptonote::network_type _nettype,
bool _enable_pusher,
bool _enable_js,
bool _enable_key_image_checker,
@ -344,12 +356,13 @@ namespace xmreg
uint64_t _no_blocks_on_index,
uint64_t _mempool_info_timeout,
string _testnet_url,
string _stagenet_url,
string _mainnet_url)
: mcore {_mcore},
core_storage {_core_storage},
rpc {_deamon_url},
server_timestamp {std::time(nullptr)},
testnet {_testnet},
nettype {_nettype},
enable_pusher {_enable_pusher},
enable_js {_enable_js},
enable_key_image_checker {_enable_key_image_checker},
@ -362,10 +375,15 @@ namespace xmreg
no_blocks_on_index {_no_blocks_on_index},
mempool_info_timeout {_mempool_info_timeout},
testnet_url {_testnet_url},
stagenet_url {_stagenet_url},
mainnet_url {_mainnet_url},
block_tx_cache(200),
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;
@ -419,6 +437,16 @@ namespace xmreg
"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["crc32.js"] +
template_file["biginteger.js"] +
@ -491,7 +519,9 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"testnet_url" , testnet_url},
{"stagenet_url" , stagenet_url},
{"mainnet_url" , mainnet_url},
{"refresh" , refresh_page},
{"height" , height},
@ -784,7 +814,7 @@ namespace xmreg
// perapre network info mstch::map for the front page
string hash_rate;
if (testnet)
if (testnet || stagenet)
{
hash_rate = std::to_string(current_network_info.hash_rate) + " H/s";
}
@ -957,6 +987,7 @@ namespace xmreg
{"age" , age_str},
{"hash" , pod_to_hex(mempool_tx.tx_hash)},
{"fee" , mempool_tx.fee_str},
{"payed_for_kB" , mempool_tx.payed_for_kB_str},
{"xmr_inputs" , mempool_tx.xmr_inputs_str},
{"xmr_outputs" , mempool_tx.xmr_outputs_str},
{"no_inputs" , mempool_tx.no_inputs},
@ -1002,6 +1033,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"blocks" , mstch::array()}
};
@ -1145,6 +1177,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"blk_hash" , blk_hash_str},
{"blk_height" , _blk_height},
{"blk_timestamp" , blk_timestamp},
@ -1471,6 +1504,7 @@ namespace xmreg
mstch::map context {
{"testnet" , this->testnet},
{"stagenet" , this->stagenet},
{"show_cache_times" , show_cache_times},
{"txs" , mstch::array{}}
};
@ -1535,7 +1569,7 @@ namespace xmreg
// parse string representing given monero address
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;
return string("Cant parse xmr address: " + xmr_address_str);
@ -1706,6 +1740,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)},
{"xmr_address" , xmr_address_str},
@ -2280,7 +2315,8 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet}
{"testnet" , testnet},
{"stagenet" , stagenet}
};
add_css_style(context);
@ -2312,6 +2348,7 @@ namespace xmreg
// initalize page template context map
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"unsigned_tx_given" , unsigned_tx_given},
{"have_raw_tx" , true},
{"has_error" , false},
@ -2389,7 +2426,7 @@ namespace xmreg
{
mstch::map dest_info {
{"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)}
};
@ -2733,7 +2770,7 @@ namespace xmreg
destination_addresses.push_back(
mstch::map {
{"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)},
{"is_this_change" , false}
}
@ -2750,7 +2787,7 @@ namespace xmreg
destination_addresses.push_back(
mstch::map {
{"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" ,
xmreg::xmr_amount_to_str(ptx.construction_data.change_dts.amount)},
{"is_this_change" , true}
@ -2934,6 +2971,7 @@ namespace xmreg
// initalize page template context map
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"have_raw_tx" , true},
{"has_error" , false},
{"error_msg" , string {}},
@ -3137,6 +3175,7 @@ namespace xmreg
// initalize page template context map
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
};
add_css_style(context);
@ -3150,7 +3189,8 @@ namespace xmreg
{
// initalize page template context map
mstch::map context {
{"testnet" , testnet}
{"testnet" , testnet},
{"stagenet" , stagenet}
};
add_css_style(context);
@ -3174,6 +3214,7 @@ namespace xmreg
// initalize page template context map
mstch::map context{
{"testnet" , testnet},
{"stagenet" , stagenet},
{"has_error" , false},
{"error_msg" , string{}},
};
@ -3262,7 +3303,7 @@ namespace xmreg
context.insert({"address" , REMOVE_HASH_BRAKETS(
xmreg::print_address(address_info, testnet))});
xmreg::print_address(address_info, nettype))});
context.insert({"viewkey" , REMOVE_HASH_BRAKETS(
fmt::format("{:s}", prv_view_key))});
context.insert({"has_total_xmr" , false});
@ -3291,7 +3332,7 @@ namespace xmreg
{"key_image" , pod_to_hex(key_image)},
{"signature" , fmt::format("{:s}", signature)},
{"address" , xmreg::print_address(
address_info, testnet)},
address_info, nettype)},
{"is_spent" , core_storage->have_tx_keyimg_as_spent(key_image)},
{"tx_hash" , string{}}
};
@ -3319,6 +3360,7 @@ namespace xmreg
// initalize page template context map
mstch::map context{
{"testnet" , testnet},
{"stagenet" , stagenet},
{"has_error" , false},
{"error_msg" , string{}}
};
@ -3395,7 +3437,7 @@ namespace xmreg
address_parse_info address_info {*xmr_address, false};
context.insert({"address" , REMOVE_HASH_BRAKETS(
xmreg::print_address(address_info, testnet))});
xmreg::print_address(address_info, nettype))});
context.insert({"viewkey" , REMOVE_HASH_BRAKETS(
fmt::format("{:s}", prv_view_key))});
context.insert({"has_total_xmr" , false});
@ -3612,19 +3654,21 @@ namespace xmreg
// parse string representing given monero address
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')
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;
return string("Cant parse address (probably incorrect format): ")
+ 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
@ -3636,7 +3680,7 @@ namespace xmreg
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;
return string("Cant parse address (probably incorrect format): ")
@ -3645,7 +3689,7 @@ namespace xmreg
return show_integrated_address_details(address_info,
address_info.payment_id,
testnet);
nettype);
}
// all_possible_tx_hashes was field using custom lmdb database
@ -3659,10 +3703,10 @@ namespace xmreg
}
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_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key);
@ -3671,7 +3715,8 @@ namespace xmreg
{"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)},
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"is_integrated_addr" , false},
{"testnet" , testnet}
{"testnet" , testnet},
{"stagenet" , stagenet},
};
add_css_style(context);
@ -3684,10 +3729,10 @@ namespace xmreg
string
show_integrated_address_details(const address_parse_info& address_info,
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_spendkey_str = fmt::format("{:s}", address_info.address.m_spend_public_key);
string enc_payment_id_str = fmt::format("{:s}", encrypted_payment_id);
@ -3698,7 +3743,8 @@ namespace xmreg
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)},
{"is_integrated_addr" , true},
{"testnet" , testnet}
{"testnet" , testnet},
{"stagenet" , stagenet},
};
add_css_style(context);
@ -3789,6 +3835,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"search_text" , search_text},
{"no_results" , true},
{"to_many_results" , false}
@ -4753,7 +4800,7 @@ namespace xmreg
// parse string representing given monero address
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["message"] = "Cant parse monero address: " + address_str;
@ -4958,7 +5005,7 @@ namespace xmreg
// parse string representing given monero address
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["message"] = "Cant parse monero address: " + address_str;
@ -5529,6 +5576,7 @@ namespace xmreg
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"testnet" , testnet},
{"stagenet" , stagenet},
{"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , string{}},
{"tx_pub_key" , pod_to_hex(txd.pk)},
@ -6176,7 +6224,8 @@ namespace xmreg
{"incoming_connections_count", local_copy_network_info.incoming_connections_count},
{"white_peerlist_size" , local_copy_network_info.white_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)},
{"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty},
{"block_size_limit" , local_copy_network_info.block_size_limit},

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

@ -24,12 +24,18 @@
{{#testnet_url}}
| <a href="{{testnet_url}}">Go to testnet explorer</a>
{{/testnet_url}}
{{#stagenet_url}}
| <a href="{{stagenet_url}}">Go to stagenet explorer</a>
{{/stagenet_url}}
{{#mainnet_url}}
| <a href="{{mainnet_url}}">Go to mainnet explorer</a>
{{/mainnet_url}}
{{#testnet}}
| This is <span style="color:#ff6b62">testnet</span> blockchian
{{/testnet}}
{{#stagenet}}
| This is <span style="color:#ff6b62">stagenet</span> blockchian
{{/stagenet}}
</h3>
@ -74,8 +80,8 @@
<td>height</td>
<td>age {{age_format}}<!--(Δm)--></td>
<td>size [kB]<!--(Δm)--></td>
<td>tx hash</td>
<td>fees</td>
<td>transaction hash</td>
<td>fee</td>
<td>outputs</td>
<td>in/out/pID</td>
<td>ring size</td>

@ -56,6 +56,13 @@ var cnUtil = (function(initConfig) {
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 CURRENT_TX_VERSION = 2;
var OLD_TX_VERSION = 1;

@ -1,5 +1,6 @@
var config = {
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,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
@ -13,6 +14,9 @@ var config = {
addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63,
addressPrefixStagenet: 24,
integratedAddressPrefixStagenet: 25,
subAddressPrefixStagenet: 36,
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
txChargeRatio: 0.5,

@ -78,10 +78,10 @@ get_tx_pub_key_from_str_hash(Blockchain& core_storage, const string& hash_str, t
bool
parse_str_address(const string& address_str,
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;
return false;
@ -95,10 +95,10 @@ parse_str_address(const string& address_str,
* Return string representation of monero address
*/
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(
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&
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;
}
@ -237,14 +237,16 @@ generate_key_image(const crypto::key_derivation& derivation,
string
get_default_lmdb_folder(bool testnet)
get_default_lmdb_folder(cryptonote::network_type nettype)
{
// default path to monero folder
// on linux this is /home/<username>/.bitmonero
string default_monero_dir = tools::get_default_data_dir();
if (testnet)
if (nettype == cryptonote::network_type::TESTNET)
default_monero_dir += "/testnet";
if (nettype == cryptonote::network_type::STAGENET)
default_monero_dir += "/stagenet";
// the default folder of the lmdb blockchain database
@ -261,10 +263,10 @@ get_default_lmdb_folder(bool testnet)
bool
get_blockchain_path(const boost::optional<string>& bc_path,
bf::path& blockchain_path,
bool testnet)
cryptonote::network_type nettype)
{
// 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
? bf::path(*bc_path)

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

Loading…
Cancel
Save