@ -38,6 +38,11 @@ bool testnet = *testnet_opt;
bool stagenet = * stagenet_opt ;
bool do_not_relay = * do_not_relay_opt ;
if ( testnet & & stagenet )
{
cerr < < " testnet and stagenet cannot be specified at the same time! " < < endl ;
return EXIT_FAILURE ;
}
// check if config-file provided exist
if ( ! boost : : filesystem : : exists ( * config_file_opt ) )
@ -63,52 +68,19 @@ catch (const std::exception& e)
return EXIT_FAILURE ;
}
//cast port number in string to uint16
uint16_t app_port = boost : : lexical_cast < uint16_t > ( * port_opt ) ;
// get blockchain path
// if confing.json paths are emtpy, defeault monero
// paths are going to be used
path blockchain_path = testnet
? path ( config_json [ " blockchain-path " ] [ " testnet " ] . get < string > ( ) )
: path ( config_json [ " blockchain-path " ] [ " mainnet " ] . get < string > ( ) ) ;
const cryptonote : : network_type nettype = testnet ?
cryptonote : : network_type : : TESTNET : stagenet ?
cryptonote : : network_type : : STAGENET : cryptonote : : network_type : : MAINNET ;
if ( ! xmreg : : get_blockchain_path ( blockchain_path , testnet ) )
{
cerr < < " Error getting blockchain path. " < < endl ;
return EXIT_FAILURE ;
}
cout < < " Blockchain path: " < < blockchain_path . string ( ) < < endl ;
string deamon_url = testnet
? config_json [ " daemon-url " ] [ " testnet " ]
: config_json [ " daemon-url " ] [ " mainnet " ] ;
// set mysql/mariadb connection details
xmreg : : MySqlConnector : : url = config_json [ " database " ] [ " url " ] ;
xmreg : : MySqlConnector : : port = config_json [ " database " ] [ " port " ] ;
xmreg : : MySqlConnector : : username = config_json [ " database " ] [ " user " ] ;
xmreg : : MySqlConnector : : password = config_json [ " database " ] [ " password " ] ;
xmreg : : MySqlConnector : : dbname = config_json [ " database " ] [ " dbname " ] ;
// get the network type
cryptonote : : network_type nettype = testnet ?
cryptonote : : network_type : : TESTNET : stagenet ?
cryptonote : : network_type : : STAGENET : cryptonote : : network_type : : MAINNET ;
// set blockchain status monitoring thread parameters
xmreg : : CurrentBlockchainStatus : : blockchain_path
= blockchain_path . string ( ) ;
xmreg : : CurrentBlockchainStatus : : net_type
= nettype ;
xmreg : : CurrentBlockchainStatus : : do_not_relay
= do_not_relay ;
xmreg : : CurrentBlockchainStatus : : deamon_url
= deamon_url ;
xmreg : : CurrentBlockchainStatus : : refresh_block_status_every_seconds
= config_json [ " refresh_block_status_every_seconds " ] ;
xmreg : : CurrentBlockchainStatus : : max_number_of_blocks_to_import
@ -118,21 +90,68 @@ xmreg::CurrentBlockchainStatus::search_thread_life_in_seconds
xmreg : : CurrentBlockchainStatus : : import_fee
= config_json [ " wallet_import " ] [ " fee " ] ;
if ( testnet )
string deamon_url ;
// get blockchain path
// if confing.json paths are emtpy, defeault monero
// paths are going to be used
path blockchain_path ;
switch ( nettype )
{
xmreg : : CurrentBlockchainStatus : : import_payment_address_str
= config_json [ " wallet_import " ] [ " testnet " ] [ " address " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_viewkey_str
= config_json [ " wallet_import " ] [ " testnet " ] [ " viewkey " ] ;
case cryptonote : : network_type : : MAINNET :
blockchain_path = path ( config_json [ " blockchain-path " ] [ " mainnet " ] . get < string > ( ) ) ;
deamon_url = config_json [ " daemon-url " ] [ " mainnet " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_address_str
= config_json [ " wallet_import " ] [ " mainnet " ] [ " address " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_viewkey_str
= config_json [ " wallet_import " ] [ " mainnet " ] [ " viewkey " ] ;
break ;
case cryptonote : : network_type : : TESTNET :
blockchain_path = path ( config_json [ " blockchain-path " ] [ " testnet " ] . get < string > ( ) ) ;
deamon_url = config_json [ " daemon-url " ] [ " testnet " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_address_str
= config_json [ " wallet_import " ] [ " testnet " ] [ " address " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_viewkey_str
= config_json [ " wallet_import " ] [ " testnet " ] [ " viewkey " ] ;
break ;
case cryptonote : : network_type : : STAGENET :
blockchain_path = path ( config_json [ " blockchain-path " ] [ " stagenet " ] . get < string > ( ) ) ;
deamon_url = config_json [ " daemon-url " ] [ " stagenet " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_address_str
= config_json [ " wallet_import " ] [ " stagenet " ] [ " address " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_viewkey_str
= config_json [ " wallet_import " ] [ " stagenet " ] [ " viewkey " ] ;
break ;
default :
cerr < < " Invalid netowork type provided: " < < static_cast < int > ( nettype ) < < " \n " ;
return EXIT_FAILURE ;
}
else
if ( ! xmreg : : get_blockchain_path ( blockchain_path , nettype ) )
{
xmreg : : CurrentBlockchainStatus : : import_payment_address_str
= config_json [ " wallet_import " ] [ " mainnet " ] [ " address " ] ;
xmreg : : CurrentBlockchainStatus : : import_payment_viewkey_str
= config_json [ " wallet_import " ] [ " mainnet " ] [ " viewkey " ] ;
cerr < < " Error getting blockchain path. \n " ;
return EXIT_FAILURE ;
}
// set remaining blockchain status variables that depend on the network type
xmreg : : CurrentBlockchainStatus : : blockchain_path
= blockchain_path . string ( ) ;
xmreg : : CurrentBlockchainStatus : : deamon_url
= deamon_url ;
cout < < " Blockchain path: " < < blockchain_path . string ( ) < < endl ;
// set mysql/mariadb connection details
xmreg : : MySqlConnector : : url = config_json [ " database " ] [ " url " ] ;
xmreg : : MySqlConnector : : port = config_json [ " database " ] [ " port " ] ;
xmreg : : MySqlConnector : : username = config_json [ " database " ] [ " user " ] ;
xmreg : : MySqlConnector : : password = config_json [ " database " ] [ " password " ] ;
xmreg : : MySqlConnector : : dbname = config_json [ " database " ] [ " dbname " ] ;
// try connecting to the mysql
shared_ptr < xmreg : : MySqlAccounts > mysql_accounts ;
@ -149,7 +168,6 @@ catch(std::exception const& e)
}
// since CurrentBlockchainStatus class monitors current status
// of the blockchain (e.g., current height), its seems logical to
// make static objects for accessing the blockchain in this class.