@ -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 ) } ,
test net { _ test net} ,
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 , test net) )
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 (
test net, 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 (
test net, 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 (
test net, 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 , test net) ) } ) ;
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 , test net) } ,
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 , test net) ) } ) ;
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 , test net_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 , test net, 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 ,
test net) ;
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 , test net) ;
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 , test net) ;
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 , test net) )
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 , test net) )
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 } ,