--enable-as-hex option added
This commit is contained in:
parent
2264d1d722
commit
22a9f6517e
19
main.cpp
19
main.cpp
|
@ -64,6 +64,7 @@ main(int ac, const char* av[])
|
||||||
auto enable_js_opt = opts.get_option<bool>("enable-js");
|
auto enable_js_opt = opts.get_option<bool>("enable-js");
|
||||||
auto enable_mixin_details_opt = opts.get_option<bool>("enable-mixin-details");
|
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_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_tx_cache_opt = opts.get_option<bool>("enable-tx-cache");
|
||||||
auto enable_block_cache_opt = opts.get_option<bool>("enable-block-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");
|
auto show_cache_times_opt = opts.get_option<bool>("show-cache-times");
|
||||||
|
@ -91,6 +92,7 @@ main(int ac, const char* av[])
|
||||||
bool enable_output_key_checker {*enable_output_key_checker_opt};
|
bool enable_output_key_checker {*enable_output_key_checker_opt};
|
||||||
bool enable_mixin_details {*enable_mixin_details_opt};
|
bool enable_mixin_details {*enable_mixin_details_opt};
|
||||||
bool enable_json_api {*enable_json_api_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_tx_cache {*enable_tx_cache_opt};
|
||||||
bool enable_block_cache {*enable_block_cache_opt};
|
bool enable_block_cache {*enable_block_cache_opt};
|
||||||
bool enable_emission_monitor {*enable_emission_monitor_opt};
|
bool enable_emission_monitor {*enable_emission_monitor_opt};
|
||||||
|
@ -262,6 +264,7 @@ main(int ac, const char* av[])
|
||||||
nettype,
|
nettype,
|
||||||
enable_pusher,
|
enable_pusher,
|
||||||
enable_js,
|
enable_js,
|
||||||
|
enable_as_hex,
|
||||||
enable_key_image_checker,
|
enable_key_image_checker,
|
||||||
enable_output_key_checker,
|
enable_output_key_checker,
|
||||||
enable_autorefresh_option,
|
enable_autorefresh_option,
|
||||||
|
@ -309,10 +312,18 @@ main(int ac, const char* av[])
|
||||||
return crow::response(xmrblocks.show_tx(remove_bad_chars(tx_hash)));
|
return crow::response(xmrblocks.show_tx(remove_bad_chars(tx_hash)));
|
||||||
});
|
});
|
||||||
|
|
||||||
CROW_ROUTE(app, "/txhex/<string>")
|
if (enable_as_hex)
|
||||||
([&](const crow::request& req, string tx_hash) {
|
{
|
||||||
return crow::response(xmrblocks.show_tx_hex(remove_bad_chars(tx_hash)));
|
CROW_ROUTE(app, "/txhex/<string>")
|
||||||
});
|
([&](const crow::request& req, string tx_hash) {
|
||||||
|
return crow::response(xmrblocks.show_tx_hex(remove_bad_chars(tx_hash)));
|
||||||
|
});
|
||||||
|
|
||||||
|
CROW_ROUTE(app, "/blockhex/<uint>")
|
||||||
|
([&](const crow::request& req, size_t block_height) {
|
||||||
|
return crow::response(xmrblocks.show_block_hex(block_height));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
CROW_ROUTE(app, "/tx/<string>/<uint>")
|
CROW_ROUTE(app, "/tx/<string>/<uint>")
|
||||||
([&](string tx_hash, uint16_t with_ring_signatures)
|
([&](string tx_hash, uint16_t with_ring_signatures)
|
||||||
|
|
|
@ -45,6 +45,8 @@ namespace xmreg
|
||||||
"enable caching of block details")
|
"enable caching of block details")
|
||||||
("enable-js", value<bool>()->default_value(false)->implicit_value(true),
|
("enable-js", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
"enable checking outputs and proving txs using JavaScript on client side")
|
"enable checking outputs and proving txs using JavaScript on client side")
|
||||||
|
("enable-as-hex", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
|
"enable links to provide hex represtations of a tx and a block")
|
||||||
("enable-autorefresh-option", value<bool>()->default_value(false)->implicit_value(true),
|
("enable-autorefresh-option", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
"enable users to have the index page on autorefresh")
|
"enable users to have the index page on autorefresh")
|
||||||
("enable-emission-monitor", value<bool>()->default_value(false)->implicit_value(true),
|
("enable-emission-monitor", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
|
|
34
src/page.h
34
src/page.h
|
@ -365,6 +365,7 @@ class page
|
||||||
bool enable_mixins_details;
|
bool enable_mixins_details;
|
||||||
bool enable_tx_cache;
|
bool enable_tx_cache;
|
||||||
bool enable_block_cache;
|
bool enable_block_cache;
|
||||||
|
bool enable_as_hex;
|
||||||
bool show_cache_times;
|
bool show_cache_times;
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,6 +416,7 @@ public:
|
||||||
cryptonote::network_type _nettype,
|
cryptonote::network_type _nettype,
|
||||||
bool _enable_pusher,
|
bool _enable_pusher,
|
||||||
bool _enable_js,
|
bool _enable_js,
|
||||||
|
bool _enable_as_hex,
|
||||||
bool _enable_key_image_checker,
|
bool _enable_key_image_checker,
|
||||||
bool _enable_output_key_checker,
|
bool _enable_output_key_checker,
|
||||||
bool _enable_autorefresh_option,
|
bool _enable_autorefresh_option,
|
||||||
|
@ -434,6 +436,7 @@ public:
|
||||||
nettype {_nettype},
|
nettype {_nettype},
|
||||||
enable_pusher {_enable_pusher},
|
enable_pusher {_enable_pusher},
|
||||||
enable_js {_enable_js},
|
enable_js {_enable_js},
|
||||||
|
enable_as_hex {_enable_as_hex},
|
||||||
enable_key_image_checker {_enable_key_image_checker},
|
enable_key_image_checker {_enable_key_image_checker},
|
||||||
enable_output_key_checker {_enable_output_key_checker},
|
enable_output_key_checker {_enable_output_key_checker},
|
||||||
enable_autorefresh_option {_enable_autorefresh_option},
|
enable_autorefresh_option {_enable_autorefresh_option},
|
||||||
|
@ -1253,11 +1256,12 @@ public:
|
||||||
{"blk_timestamp_epoch" , blk.timestamp},
|
{"blk_timestamp_epoch" , blk.timestamp},
|
||||||
{"prev_hash" , prev_hash_str},
|
{"prev_hash" , prev_hash_str},
|
||||||
{"next_hash" , next_hash_str},
|
{"next_hash" , next_hash_str},
|
||||||
|
{"enable_as_hex" , enable_as_hex},
|
||||||
{"have_next_hash" , have_next_hash},
|
{"have_next_hash" , have_next_hash},
|
||||||
{"have_prev_hash" , have_prev_hash},
|
{"have_prev_hash" , have_prev_hash},
|
||||||
{"have_txs" , have_txs},
|
{"have_txs" , have_txs},
|
||||||
{"no_txs" , std::to_string(
|
{"no_txs" , std::to_string(
|
||||||
blk.tx_hashes.size())},
|
blk.tx_hashes.size())},
|
||||||
{"blk_age" , age.first},
|
{"blk_age" , age.first},
|
||||||
{"delta_time" , delta_time},
|
{"delta_time" , delta_time},
|
||||||
{"blk_nonce" , blk.nonce},
|
{"blk_nonce" , blk.nonce},
|
||||||
|
@ -1632,9 +1636,34 @@ public:
|
||||||
}
|
}
|
||||||
catch (std::exception const& e)
|
catch (std::exception const& e)
|
||||||
{
|
{
|
||||||
cerr << e.what() << endl;
|
cerr << e.what() << endl;
|
||||||
return string {"Failed to obtain hex of tx due to: "} + e.what();
|
return string {"Failed to obtain hex of tx due to: "} + e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
show_block_hex(size_t block_height)
|
||||||
|
{
|
||||||
|
|
||||||
|
// get transaction
|
||||||
|
block blk;
|
||||||
|
|
||||||
|
if (!mcore->get_block_by_height(block_height, blk))
|
||||||
|
{
|
||||||
|
cerr << "Cant get block in blockchain: " << block_height
|
||||||
|
<< ". \n Check mempool now\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return epee::string_tools::buff_to_hex_nodelimer(
|
||||||
|
t_serializable_object_to_blob(blk));
|
||||||
|
}
|
||||||
|
catch (std::exception const& e)
|
||||||
|
{
|
||||||
|
cerr << e.what() << endl;
|
||||||
|
return string {"Failed to obtain hex of a block due to: "} + e.what();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
@ -6063,6 +6092,7 @@ private:
|
||||||
context["inputs_xmr_sum"] = xmreg::xmr_amount_to_str(inputs_xmr_sum);
|
context["inputs_xmr_sum"] = xmreg::xmr_amount_to_str(inputs_xmr_sum);
|
||||||
context["server_time"] = server_time_str;
|
context["server_time"] = server_time_str;
|
||||||
context["enable_mixins_details"] = detailed_view;
|
context["enable_mixins_details"] = detailed_view;
|
||||||
|
context["enable_as_hex"] = enable_as_hex;
|
||||||
context["show_part_of_inputs"] = show_part_of_inputs;
|
context["show_part_of_inputs"] = show_part_of_inputs;
|
||||||
context["max_no_of_inputs_to_show"] = max_no_of_inputs_to_show;
|
context["max_no_of_inputs_to_show"] = max_no_of_inputs_to_show;
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,13 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{/blk_txs}}
|
{{/blk_txs}}
|
||||||
</table>
|
</table>
|
||||||
{{/have_txs}}
|
{{/have_txs}}
|
||||||
|
|
||||||
|
|
||||||
|
{{#enable_as_hex}}
|
||||||
|
<h5 style="margin-top:1px">
|
||||||
|
<a href="/blockhex/{{blk_height}}">Block as hex</a>
|
||||||
|
</h5>
|
||||||
|
{{/enable_as_hex}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -533,7 +533,9 @@
|
||||||
{{#show_more_details_link}}
|
{{#show_more_details_link}}
|
||||||
<h5 style="margin-top:1px">
|
<h5 style="margin-top:1px">
|
||||||
<a href="/tx/{{tx_hash}}/1">More details</a>
|
<a href="/tx/{{tx_hash}}/1">More details</a>
|
||||||
| <a href="/txhex/{{tx_hash}}">As hex</a>
|
{{#enable_as_hex}}
|
||||||
|
| <a href="/txhex/{{tx_hash}}">Tx as hex</a>
|
||||||
|
{{/enable_as_hex}}
|
||||||
</h5>
|
</h5>
|
||||||
{{/show_more_details_link}}
|
{{/show_more_details_link}}
|
||||||
{{/with_ring_signatures}}
|
{{/with_ring_signatures}}
|
||||||
|
|
Loading…
Reference in New Issue