@ -44,6 +44,7 @@ main(int ac, const char* av[])
}
auto port_opt = opts . get_option < string > ( " port " ) ;
auto bindaddr_opt = opts . get_option < string > ( " bindaddr " ) ;
auto bc_path_opt = opts . get_option < string > ( " bc-path " ) ;
auto deamon_url_opt = opts . get_option < string > ( " deamon-url " ) ;
auto ssl_crt_file_opt = opts . get_option < string > ( " ssl-crt-file " ) ;
@ -63,6 +64,7 @@ main(int ac, const char* av[])
auto enable_js_opt = opts . get_option < bool > ( " enable-js " ) ;
auto enable_mixin_details_opt = opts . get_option < bool > ( " enable-mixin-details " ) ;
auto enable_json_api_opt = opts . get_option < bool > ( " enable-json-api " ) ;
auto enable_as_hex_opt = opts . get_option < bool > ( " enable-as-hex " ) ;
auto enable_tx_cache_opt = opts . get_option < bool > ( " enable-tx-cache " ) ;
auto enable_block_cache_opt = opts . get_option < bool > ( " enable-block-cache " ) ;
auto show_cache_times_opt = opts . get_option < bool > ( " show-cache-times " ) ;
@ -90,6 +92,7 @@ main(int ac, const char* av[])
bool enable_output_key_checker { * enable_output_key_checker_opt } ;
bool enable_mixin_details { * enable_mixin_details_opt } ;
bool enable_json_api { * enable_json_api_opt } ;
bool enable_as_hex { * enable_as_hex_opt } ;
bool enable_tx_cache { * enable_tx_cache_opt } ;
bool enable_block_cache { * enable_block_cache_opt } ;
bool enable_emission_monitor { * enable_emission_monitor_opt } ;
@ -100,9 +103,13 @@ main(int ac, const char* av[])
uint32_t log_level = 0 ;
mlog_configure ( " " , true ) ;
( void ) log_level ;
//cast port number in string to uint
uint16_t app_port = boost : : lexical_cast < uint16_t > ( * port_opt ) ;
string bindaddr = * bindaddr_opt ;
// cast no_blocks_on_index_opt to uint
uint64_t no_blocks_on_index = boost : : lexical_cast < uint64_t > ( * no_blocks_on_index_opt ) ;
@ -259,6 +266,7 @@ main(int ac, const char* av[])
nettype ,
enable_pusher ,
enable_js ,
enable_as_hex ,
enable_key_image_checker ,
enable_output_key_checker ,
enable_autorefresh_option ,
@ -282,7 +290,7 @@ main(int ac, const char* av[])
} ;
CROW_ROUTE ( app , " / " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return crow : : response ( xmrblocks . index2 ( ) ) ;
} ) ;
@ -292,20 +300,43 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /block/<uint> " )
( [ & ] ( const crow : : request & req , size_t block_height ) {
( [ & ] ( size_t block_height ) {
return crow : : response ( xmrblocks . show_block ( block_height ) ) ;
} ) ;
CROW_ROUTE ( app , " /block/<string> " )
( [ & ] ( const crow : : request & req , string block_hash ) {
( [ & ] ( string block_hash ) {
return crow : : response ( xmrblocks . show_block ( remove_bad_chars ( block_hash ) ) ) ;
} ) ;
CROW_ROUTE ( app , " /tx/<string> " )
( [ & ] ( const crow : : request & req , string tx_hash ) {
( [ & ] ( string tx_hash ) {
return crow : : response ( xmrblocks . show_tx ( remove_bad_chars ( tx_hash ) ) ) ;
} ) ;
if ( enable_as_hex )
{
CROW_ROUTE ( app , " /txhex/<string> " )
( [ & ] ( string tx_hash ) {
return crow : : response ( xmrblocks . show_tx_hex ( remove_bad_chars ( tx_hash ) ) ) ;
} ) ;
CROW_ROUTE ( app , " /ringmembershex/<string> " )
( [ & ] ( string tx_hash ) {
return crow : : response ( xmrblocks . show_ringmembers_hex ( remove_bad_chars ( tx_hash ) ) ) ;
} ) ;
CROW_ROUTE ( app , " /blockhex/<uint> " )
( [ & ] ( size_t block_height ) {
return crow : : response ( xmrblocks . show_block_hex ( block_height , false ) ) ;
} ) ;
CROW_ROUTE ( app , " /blockhexcomplete/<uint> " )
( [ & ] ( size_t block_height ) {
return crow : : response ( xmrblocks . show_block_hex ( block_height , true ) ) ;
} ) ;
}
CROW_ROUTE ( app , " /tx/<string>/<uint> " )
( [ & ] ( string tx_hash , uint16_t with_ring_signatures )
{
@ -403,7 +434,7 @@ main(int ac, const char* av[])
if ( enable_pusher )
{
CROW_ROUTE ( app , " /rawtx " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . show_rawtx ( ) ;
} ) ;
@ -433,7 +464,7 @@ main(int ac, const char* av[])
if ( enable_key_image_checker )
{
CROW_ROUTE ( app , " /rawkeyimgs " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . show_rawkeyimgs ( ) ;
} ) ;
@ -464,7 +495,7 @@ main(int ac, const char* av[])
if ( enable_output_key_checker )
{
CROW_ROUTE ( app , " /rawoutputkeys " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . show_rawoutputkeys ( ) ;
} ) ;
@ -499,13 +530,13 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /mempool " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . mempool ( true ) ;
} ) ;
// alias to "/mempool"
CROW_ROUTE ( app , " /txpool " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . mempool ( true ) ;
} ) ;
@ -526,52 +557,52 @@ main(int ac, const char* av[])
cout < < " Enable JavaScript checking of outputs and proving txs \n " ;
CROW_ROUTE ( app , " /js/jquery.min.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " jquery.min.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/crc32.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " crc32.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/biginteger.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " biginteger.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/crypto.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " crypto.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/config.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " config.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/nacl-fast-cn.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " nacl-fast-cn.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/base58.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " base58.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/cn_util.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " cn_util.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/sha3.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
return xmrblocks . get_js_file ( " sha3.js " ) ;
} ) ;
CROW_ROUTE ( app , " /js/all_in_one.js " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
// /js/all_in_one.js file does not exist. it is generated on the fly
// from the above real files.
return xmrblocks . get_js_file ( " all_in_one.js " ) ;
@ -585,7 +616,7 @@ main(int ac, const char* av[])
cout < < " Enable JSON API \n " ;
CROW_ROUTE ( app , " /api/transaction/<string> " )
( [ & ] ( const crow : : request & req , string tx_hash ) {
( [ & ] ( string tx_hash ) {
myxmr : : jsonresponse r { xmrblocks . json_transaction ( remove_bad_chars ( tx_hash ) ) } ;
@ -593,15 +624,23 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/rawtransaction/<string> " )
( [ & ] ( const crow : : request & req , string tx_hash ) {
( [ & ] ( string tx_hash ) {
myxmr : : jsonresponse r { xmrblocks . json_rawtransaction ( remove_bad_chars ( tx_hash ) ) } ;
return r ;
} ) ;
CROW_ROUTE ( app , " /api/detailedtransaction/<string> " )
( [ & ] ( string tx_hash ) {
myxmr : : jsonresponse r { xmrblocks . json_detailedtransaction ( remove_bad_chars ( tx_hash ) ) } ;
return r ;
} ) ;
CROW_ROUTE ( app , " /api/block/<string> " )
( [ & ] ( const crow : : request & req , string block_no_or_hash ) {
( [ & ] ( string block_no_or_hash ) {
myxmr : : jsonresponse r { xmrblocks . json_block ( remove_bad_chars ( block_no_or_hash ) ) } ;
@ -609,7 +648,7 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/rawblock/<string> " )
( [ & ] ( const crow : : request & req , string block_no_or_hash ) {
( [ & ] ( string block_no_or_hash ) {
myxmr : : jsonresponse r { xmrblocks . json_rawblock ( remove_bad_chars ( block_no_or_hash ) ) } ;
@ -650,7 +689,7 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/search/<string> " )
( [ & ] ( const crow : : request & req , string search_value ) {
( [ & ] ( string search_value ) {
myxmr : : jsonresponse r { xmrblocks . json_search ( remove_bad_chars ( search_value ) ) } ;
@ -658,7 +697,7 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/networkinfo " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
myxmr : : jsonresponse r { xmrblocks . json_networkinfo ( ) } ;
@ -666,7 +705,7 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/emission " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
myxmr : : jsonresponse r { xmrblocks . json_emission ( ) } ;
@ -742,7 +781,7 @@ main(int ac, const char* av[])
} ) ;
CROW_ROUTE ( app , " /api/version " )
( [ & ] ( const crow : : request & req ) {
( [ & ] ( ) {
myxmr : : jsonresponse r { xmrblocks . json_version ( ) } ;
@ -766,13 +805,13 @@ main(int ac, const char* av[])
if ( use_ssl )
{
cout < < " Staring in ssl mode " < < endl ;
app . port( app_port ) . ssl_file ( ssl_crt_file , ssl_key_file )
app . bindaddr( bindaddr ) . port( app_port ) . ssl_file ( ssl_crt_file , ssl_key_file )
. multithreaded ( ) . run ( ) ;
}
else
{
cout < < " Staring in non-ssl mode " < < endl ;
app . port( app_port ) . multithreaded ( ) . run ( ) ;
app . bindaddr( bindaddr ) . port( app_port ) . multithreaded ( ) . run ( ) ;
}