payment id added to tx.html

master
moneroexamples 9 years ago
parent c323f61adf
commit e9d07b072c

@ -71,6 +71,9 @@ namespace xmreg {
size_t version; size_t version;
uint64_t unlock_time; uint64_t unlock_time;
crypto::hash payment_id = null_hash; // normal
crypto::hash8 payment_id8 = null_hash8; // encrypted
std::vector<std::vector<crypto::signature> > signatures; std::vector<std::vector<crypto::signature> > signatures;
// key images of inputs // key images of inputs
@ -88,18 +91,27 @@ namespace xmreg {
string tx_pk_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", pk)); string tx_pk_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", pk));
cout << "payment_id: " << payment_id << endl;
string pid_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", payment_id));
string pid8_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", payment_id8));
mstch::map txd_map { mstch::map txd_map {
{"hash" , tx_hash_str}, {"hash" , tx_hash_str},
{"pub_key" , tx_pk_str}, {"pub_key" , tx_pk_str},
{"tx_fee" , fmt::format("{:0.6f}", XMR_AMOUNT(fee))}, {"tx_fee" , fmt::format("{:0.6f}", XMR_AMOUNT(fee))},
{"sum_inputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_inputs))}, {"sum_inputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_inputs))},
{"sum_outputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_outputs))}, {"sum_outputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_outputs))},
{"no_inputs" , input_key_imgs.size()}, {"no_inputs" , input_key_imgs.size()},
{"no_outputs" , output_pub_keys.size()}, {"no_outputs" , output_pub_keys.size()},
{"mixin" , std::to_string(mixin_no - 1)}, {"mixin" , std::to_string(mixin_no - 1)},
{"version" , std::to_string(version)}, {"version" , std::to_string(version)},
{"unlock_time" , std::to_string(unlock_time)}, {"has_payment_id" , payment_id != null_hash},
{"tx_size" , fmt::format("{:0.4f}", static_cast<double>(size)/1024.0)} {"has_payment_id8" , payment_id8 != null_hash8},
{"payment_id" , pid_str},
{"payment_id8" , pid8_str},
{"unlock_time" , std::to_string(unlock_time)},
{"tx_size" , fmt::format("{:0.4f}", static_cast<double>(size)/1024.0)}
}; };
@ -695,19 +707,26 @@ namespace xmreg {
tx_blk_height_str = std::to_string(tx_blk_height); tx_blk_height_str = std::to_string(tx_blk_height);
} }
// payments id. both normal and encrypted (payment_id8)
string pid_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.payment_id));
string pid8_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.payment_id8));
// 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_id8" , txd.payment_id8 != null_hash8},
{"payment_id" , pid_str},
{"payment_id8" , pid8_str},
}; };
string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F"); string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F");
@ -944,6 +963,8 @@ namespace xmreg {
txd.fee = get_tx_fee(tx); txd.fee = get_tx_fee(tx);
} }
get_payment_id(tx, txd.payment_id, txd.payment_id8);
// get tx size in bytes // get tx size in bytes
txd.size = get_object_blobsize(tx); txd.size = get_object_blobsize(tx);

@ -1,8 +1,17 @@
<div> <div>
<H4>Tx hash: {{tx_hash}}</H4> <H4 style="margin:5px">Tx hash: {{tx_hash}}</H4>
<H5>Tx public key: {{tx_pub_key}}</H5> <H5 style="margin:5px">Tx public key: {{tx_pub_key}}</H5>
{{#has_payment_id}}
<H5 style="margin:5px">Payment id: {{payment_id}}</H5>
{{/has_payment_id}}
{{#has_payment_id8}}
<H5 style="margin:5px">Payment id (encrypted): {{payment_id8}}</H5>
{{/has_payment_id8}}
{{#have_prev_hash}} {{#have_prev_hash}}
@ -15,7 +24,7 @@
<table class="center" style="width: 80%"> <table class="center" style="width: 80%; margin-top:10px">
<tr> <tr>
<td>Block: {{blk_height}}</td> <td>Block: {{blk_height}}</td>
<td>Timestamp [UCT]: {{blk_timestamp}}</td> <td>Timestamp [UCT]: {{blk_timestamp}}</td>

Loading…
Cancel
Save