showing tx with and without ring signatures added

This commit is contained in:
moneroexamples 2016-04-30 10:17:47 +08:00
parent 88701d0d91
commit c47d53f6e0
3 changed files with 32 additions and 15 deletions

View file

@ -94,6 +94,11 @@ int main(int ac, const char* av[]) {
return xmrblocks.show_tx(tx_hash); return xmrblocks.show_tx(tx_hash);
}); });
CROW_ROUTE(app, "/tx/<string>/<uint>")
([&](string tx_hash, uint with_ring_signatures) {
return xmrblocks.show_tx(tx_hash, with_ring_signatures);
});
CROW_ROUTE(app, "/search").methods("GET"_method) CROW_ROUTE(app, "/search").methods("GET"_method)
([&](const crow::request& req) { ([&](const crow::request& req) {

View file

@ -620,7 +620,7 @@ namespace xmreg {
} }
string string
show_tx(string tx_hash_str) show_tx(string tx_hash_str, uint with_ring_signatures = 0)
{ {
// parse tx hash string to hash object // parse tx hash string to hash object
@ -715,20 +715,21 @@ namespace xmreg {
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))}, {"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))},
{"blk_height" , tx_blk_height_str}, {"blk_height" , tx_blk_height_str},
{"tx_size" , fmt::format("{:0.4f}", {"tx_size" , fmt::format("{:0.4f}",
static_cast<double>(txd.size) / 1024.0)}, static_cast<double>(txd.size) / 1024.0)},
{"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))}, {"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))},
{"blk_timestamp" , blk_timestamp}, {"blk_timestamp" , blk_timestamp},
{"delta_time" , age.first}, {"delta_time" , age.first},
{"inputs_no" , txd.input_key_imgs.size()}, {"inputs_no" , txd.input_key_imgs.size()},
{"outputs_no" , txd.output_pub_keys.size()}, {"outputs_no" , txd.output_pub_keys.size()},
{"has_payment_id" , txd.payment_id != null_hash}, {"has_payment_id" , txd.payment_id != null_hash},
{"has_payment_id8" , txd.payment_id8 != null_hash8}, {"has_payment_id8" , txd.payment_id8 != null_hash8},
{"payment_id" , pid_str}, {"payment_id" , pid_str},
{"payment_id8" , pid8_str}, {"payment_id8" , pid8_str},
{"with_ring_signatures" , static_cast<bool>(with_ring_signatures)}
}; };
string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F"); string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F");

View file

@ -97,6 +97,8 @@
</tr> </tr>
{{#with_ring_signatures}}
<tr> <tr>
<td colspan="2"> <td colspan="2">
<table style="width:100%; margin-bottom:20px"> <table style="width:100%; margin-bottom:20px">
@ -112,10 +114,19 @@
</td> </td>
</tr> </tr>
{{/with_ring_signatures}}
{{/inputs}} {{/inputs}}
</table> </table>
{{^with_ring_signatures}}
<h5 style="margin-top:1px"><a href="/tx/{{tx_hash}}/1">Show this tx with ring signature for each input</a></h5>
{{/with_ring_signatures}}
{{#with_ring_signatures}}
<h5 style="margin-top:1px"><a href="/tx/{{tx_hash}}">Show this tx without ring signature for each input</a></h5>
{{/with_ring_signatures}}
</div> </div>