ring signatures added to tx info

master
moneroexamples 9 years ago
parent 178447f8e7
commit e376b87cfb

@ -55,6 +55,8 @@ namespace xmreg {
size_t version;
uint64_t unlock_time;
std::vector<std::vector<crypto::signature> > signatures;
// key images of inputs
vector<txin_to_key> input_key_imgs;
@ -70,7 +72,7 @@ namespace xmreg {
string tx_pk_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", pk));
return mstch::map {
mstch::map txd_map {
{"hash" , tx_hash_str},
{"pub_key" , tx_pk_str},
{"tx_fee" , fmt::format("{:0.6f}", XMR_AMOUNT(fee))},
@ -83,6 +85,39 @@ namespace xmreg {
{"unlock_time" , std::to_string(unlock_time)},
{"tx_size" , fmt::format("{:0.4f}", static_cast<double>(size)/1024.0)}
};
return txd_map;
}
mstch::array
get_ring_sig_for_input(uint64_t in_i)
{
mstch::array ring_sigs {};
if (in_i >= signatures.size())
{
return ring_sigs;
}
for (const crypto::signature &sig: signatures.at(in_i))
{
cout << print_sig(sig) << endl;
ring_sigs.push_back(mstch::map{{"ring_sig", print_signature(sig)}});
}
return ring_sigs;
}
string
print_signature(const signature& sig)
{
stringstream ss;
ss << epee::string_tools::pod_to_hex(sig.c)
<< epee::string_tools::pod_to_hex(sig.r);
return ss.str();
}
};
@ -593,12 +628,22 @@ namespace xmreg {
cerr << "Cant get block: " << tx_blk_height << endl;
}
cout << "tx_blk_height: " << tx_blk_height << endl;
// calculate difference between tx and server timestamps
pair<string, string> age = get_age(server_timestamp,
blk.timestamp, FULL_AGE_FORMAT);
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"tx_hash" , tx_hash_str},
{"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))},
{"blk_height" , tx_blk_height},
{"tx_size" , fmt::format("{:0.2f}",
static_cast<double>(txd.size) / 1024.0)},
{"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))},
{"blk_timestamp" , xmreg::timestamp_to_str(blk.timestamp)},
{"delta_time" , age.first},
{"inputs_no" , txd.input_key_imgs.size()},
{"outputs_no" , txd.output_pub_keys.size()}
};
@ -632,10 +677,13 @@ namespace xmreg {
inputs.push_back(mstch::map {
{"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))},
{"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))},
{"input_idx" , fmt::format("{:02d}", input_idx++)},
{"input_idx" , fmt::format("{:02d}", input_idx)},
{"mixins" , mstch::array{}},
{"ring_sigs" , txd.get_ring_sig_for_input(input_idx)}
});
// get reference to mixins array created above
mstch::array& mixins = boost::get<mstch::array>(
boost::get<mstch::map>(inputs.back())["mixins"]);
@ -698,7 +746,8 @@ namespace xmreg {
mixin_timestamps.push_back(blk.timestamp);
++count;
}
} // for (const uint64_t &i: absolute_offsets)
// get mixins in time scale for visual representation
pair<string, double> mixin_times_scale = xmreg::timestamps_time_scale(
@ -711,7 +760,9 @@ namespace xmreg {
// save the string timescales for later to show
mixins_timescales.push_back(mstch::map {
{"timescale", mixin_times_scale.first}});
}
input_idx++;
} // for (const txin_to_key& in_key: txd.input_key_imgs)
context["server_time"] = server_time_str;
context["inputs"] = inputs;
@ -780,6 +831,8 @@ namespace xmreg {
txd.input_key_imgs = get_key_images(tx);
txd.output_pub_keys = get_ouputs(tx);
// get tx signatures for each input
txd.signatures = tx.signatures;
// get tx version
txd.version = tx.version;

@ -1,7 +1,8 @@
<div>
<H4>Tx hash (block height): {{tx_hash}} ({{blk_height}})</H4>
<H4>Tx hash: {{tx_hash}}</H4>
<H3>Tx public key: {{tx_pub_key}}</H3>
{{#have_prev_hash}}
@ -14,21 +15,13 @@
<table class="center">
<tr>
<td>Timestamp [UCT]:</td><td>{{blk_timestamp}}</td>
<td>Age {{age_format}}:</td><td>{{blk_age}}</td>
<td>Δ [h:m:s]:</td><td>{{delta_time}}</td>
</tr>
<table class="center" style="width: 80%">
<tr>
<td>Major.minor version:</td><td>{{major_ver}}.{{minor_ver}}</td>
<td>Block reward:</td><td>{{blk_reward}}</td>
<td>Block size [kB]:</td><td>{{blk_size}}</td>
</tr>
<tr>
<td>nonce:</td><td>{{blk_nonce}}</td>
<td>Total fees:</td><td>{{sum_fees}}</td>
<td>No of txs:</td><td>{{no_txs}}</td>
<td>Block: {{blk_height}}</td>
<td>Timestamp [UCT]: {{blk_timestamp}}</td>
<td>Age [y:d:h:m:s]: {{delta_time}}</td>
<td>Fee: {{tx_fee}}</td>
<td>Tx size: {{tx_size}} kB</td>
</tr>
</table>
@ -37,7 +30,7 @@
<div class="center">
<table class="center" >
<tr>
<td>out_pub_key</td>
<td>Outputs public keys</td>
<td>amount</td>
</tr>
{{#outputs}}
@ -89,14 +82,29 @@
<td>{{mix_timestamp}}</td>
<td>{{mix_age}}</td>
</tr>
<!-- <tr>
<td>{{mix_tx_hash}}</td> <td>{{mix_out_indx}}</td><td></td><td></td>
</tr>-->
{{/mixins}}
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%; margin-bottom:20px">
<tr>
<td>Ring signature</td>
</tr>
{{#ring_sigs}}
<tr>
<td>{{ring_sig}}</td>
</tr>
{{/ring_sigs}}
</table>
</td>
</tr>
{{/inputs}}
</table>
</div>

Loading…
Cancel
Save