showing signed tx details started

master
moneroexamples 8 years ago
parent 1d26c3e791
commit 16f6785bad

@ -1652,19 +1652,11 @@ namespace xmreg {
size_t output_i {0};
cout << tx_source.amount << endl;
// cout << tx_source.amount << endl;
for(const tx_source_entry::output_entry& oe: tx_source.outputs)
{
// tx_out_index toi = core_storage->get_db()
// .get_output_tx_and_index_from_global(oe.first);
//cout << "oe.first: " << oe.first << endl;
// tx_out_index toi = core_storage->get_db()
// .get_output_tx_and_index(tx_source.amount, oe.first);
tx_out_index toi = core_storage->get_db()
.get_output_tx_and_index(0, oe.first);
@ -1725,8 +1717,52 @@ namespace xmreg {
return string("deserialization of unsigned tx data NOT successful. "
"Maybe its not base64 encoded?");
}
} // if (unsigned_tx_given)
else
{
// if raw data is not unsigined tx, then assume it is signed tx
const size_t magiclen = strlen(SIGNED_TX_PREFIX);
if (strncmp(decoded_raw_tx_data.c_str(), SIGNED_TX_PREFIX, magiclen) != 0)
{
cout << "The data is neigther unsigned nor signed tx!" << endl;
return string( "The data is neither unsigned nor signed tx!");
}
::tools::wallet2::signed_tx_set signed_txs;
bool r = serialization::parse_binary(std::string(
decoded_raw_tx_data.c_str() + magiclen,
decoded_raw_tx_data.size() - magiclen),
signed_txs);
if (!r)
{
cerr << "deserialization of signed tx data NOT successful" << endl;
return string("deserialization of signed tx data NOT successful. "
"Maybe its not base64 encoded?");
}
std::vector<tools::wallet2::pending_tx> ptxs = signed_txs.ptx;
context.insert({"signed_txs", mstch::array{}});
for (tools::wallet2::pending_tx& ptx: ptxs)
{
tx_details txd = get_tx_details(ptx.tx);
mstch::map txd_map = txd.get_mstch_map();
boost::get<mstch::array>(context["signed_txs"]).push_back(txd_map);
}
}
map<string, string> partials {
{"tx_details", xmreg::read(string(TMPL_PARIALS_DIR) + "/tx_details.html")},
};
// read checkrawtx.html
string checkrawtx_html = xmreg::read(TMPL_MY_CHECKRAWTX);
@ -1734,7 +1770,7 @@ namespace xmreg {
string full_page = checkrawtx_html + xmreg::read(TMPL_FOOTER);
// render the page
return mstch::render(full_page, context);
return mstch::render(full_page, context, partials);
}
@ -2405,15 +2441,10 @@ namespace xmreg {
// get unlock time
txd.unlock_time = tx.unlock_time;
try
if (core_storage->have_tx(txd.hash))
{
txd.blk_height = core_storage->get_db().get_tx_block_height(txd.hash);
}
catch (exception& e)
{
cerr << "Cant get block height: " << txd.hash << e.what() << endl;
txd.blk_height = 0;
}
return txd;
}

@ -138,46 +138,58 @@
<div class="center">
<h3>Details of submitted raw tx data</h3>
<h4>unsigned_tx_given: {{unsigned_tx_given}}</h4>
{{#txs}}
<div class="center" style="width: 100%; margin-top:10px">
<h4>Destination information</h4>
<div class="center" style="width: 100%;">
{{#dest_infos}}
Send {{dest_amount}} to {{dest_address}}<br/>
{{/dest_infos}}
</div>
<h4>Outputs selected for this tx (total: {{sum_outputs_amounts}})</h4>
{{#dest_sources}}
<table style="width: 100%; margin-top:10px">
<tr>
<td>Output Index</td>
<td>Stealth address</td>
<td>Is this real output</td>
<td>Age {{age_format}}</td>
<td>Amount</td>
</tr>
{{#outputs}}
{{#unsigned_tx_given}}
<h4>unsigned_tx_given: {{unsigned_tx_given}}</h4>
{{#txs}}
<div class="center" style="width: 100%; margin-top:10px">
<h4>Destination information</h4>
<div class="center" style="width: 100%;">
{{#dest_infos}}
Send {{dest_amount}} to {{dest_address}}<br/>
{{/dest_infos}}
</div>
<h4>Outputs selected for this tx (total: {{sum_outputs_amounts}})</h4>
{{#dest_sources}}
<table style="width: 100%; margin-top:10px">
<tr>
<td>{{out_index}}</td>
<td><a href="/tx/{{tx_hash}}">{{out_pub_key}}</a></td>
{{#is_real}}
<td><span style="color: #008009;font-weight: bold">{{is_real}}</span></td>
{{/is_real}}
{{^is_real}}
<td>{{is_real}}</td>
{{/is_real}}
<td>{{output_age}}</td>
<td>{{output_amount}}</td>
<td>Output Index</td>
<td>Stealth address</td>
<td>Is this real output</td>
<td>Age {{age_format}}</td>
<td>Amount</td>
</tr>
<!-- <tr><td colspan="3">&nbsp; &nbsp; ctkey: {{ctkey}}</td></tr>-->
{{/outputs}}
</table>
{{/dest_sources}}
<h4>Change to be returned to the sender</h4>
Amount: {{change_amount}}
</div>
{{/txs}}
{{#outputs}}
<tr>
<td>{{out_index}}</td>
<td><a href="/tx/{{tx_hash}}">{{out_pub_key}}</a></td>
{{#is_real}}
<td><span style="color: #008009;font-weight: bold">{{is_real}}</span></td>
{{/is_real}}
{{^is_real}}
<td>{{is_real}}</td>
{{/is_real}}
<td>{{output_age}}</td>
<td>{{output_amount}}</td>
</tr>
<!-- <tr><td colspan="3">&nbsp; &nbsp; ctkey: {{ctkey}}</td></tr>-->
{{/outputs}}
</table>
{{/dest_sources}}
<h4>Change to be returned to the sender</h4>
Amount: {{change_amount}}
</div>
{{/txs}}
{{/unsigned_tx_given}}
{{^unsigned_tx_given}}
<h4>signed_tx_given</h4>
{{#signed_txs}}
{{>tx_details}}
{{/signed_txs}}
{{/unsigned_tx_given}}
</div>

@ -0,0 +1,197 @@
<div>
<H4 style="margin:5px">Tx hash: {{tx_hash}}</H4>
<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}}
<H5>Previous tx: <a href="/tx/{{prev_hash}}">{{prev_hash}}</a></H5>
{{/have_prev_hash}}
{{#have_next_hash}}
<H5>Next tx: <a href="/tx/{{next_hash}}">{{next_hash}}</a></H5>
{{/have_next_hash}}
<table class="center" style="width: 80%; margin-top:10px">
<tr>
<td>Timestamp: {{blk_timestamp_uint}}</td>
<td>Timestamp [UCT]: {{blk_timestamp}}</td>
<td>Age [y:d:h:m:s]: {{delta_time}}</td>
</tr>
<tr>
<td>Block: <a href="/block/{{blk_height}}">{{blk_height}}</a></td>
<td>Fee: {{tx_fee}}</td>
<td>Tx size: {{tx_size}} kB</td>
</tr>
<tr>
<td>Tx version: {{tx_version}}</td>
</tr>
<tr>
<td colspan="5">Extra: {{extra}}</td>
</tr>
</table>
<h3>{{outputs_no}} output(s) for total of {{outputs_xmr_sum}} xmr</h3>
<div class="center">
<table class="center">
<tr>
<td>stealth address</td>
<td>amount</td>
<td>amount idx</td>
</tr>
{{#outputs}}
<tr>
<td>{{output_idx}}: {{out_pub_key}}</td>
<td>{{amount}}</td>
<td>{{amount_idx}} of {{num_outputs}}</td>
</tr>
{{/outputs}}
</table>
</div>
<div class="center" style="width:90%">
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Decode outputs</label>
<div class="content">
<h4 style="margin: 0px">Check which outputs belong to given Moenro address and viewkey</h4>
<form action="/myoutputs" method="get" style="width:100%; margin-top:2px" class="style-1">
<input type="hidden" name="tx_hash" size="90" value="{{tx_hash}}"><br/>
<input type="text" name="xmr_address" size="90" placeholder="Monero address"><br/>
<input type="text" name="viewkey" size="90" placeholder="viewkey" style="margin-top:5px"><br/>
<input type="submit" value="Decode outputs" style="margin-top:5px" >
</form>
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Prove sending</label>
<div class="content">
<h4 style="margin: 0px">Prove to someone that you send them Monero in this transaction</h4>
<h5 style="margin: 0px">Tx private key can be obtained using <i>get_tx_key</i>
command in <i>monero-wallet-cli</i> command line tool</h5>
<form action="/prove" method="get" style="width:100%;margin-top:2px" class="style-1">
<input type="hidden" name="txhash" size="90" value="{{tx_hash}}"><br/>
<input type="text" name="txprvkey" size="90" placeholder="Tx private key"><br/>
<input type="text" name="xmraddress" size="90"placeholder="Recipient's Monero Address" style="margin-top:5px"><br/>
<input type="submit" value="Prove" style="margin-top:5px">
</form>
</div>
</div>
</div>
</div>
{{#has_inputs}}
<h3>Inputs' mixins time scale (from {{min_mix_time}} till {{max_mix_time}};
resolution: {{timescales_scale}} days)</h3>
<div class="center">
<ul class="center">
{{#timescales}}
<li style="list-style-type: none; text-align: center; font-size: 8px">|{{timescale}}|</li>
{{/timescales}}
</ul>
</div>
<h3>{{inputs_no}} inputs(s) for total of {{inputs_xmr_sum}} xmr</h3>
<div class="center">
<table class="center">
{{#inputs}}
<tr>
<td style="text-align: left;">key image {{input_idx}}: {{in_key_img}}</td>
<td>amount: {{amount}}</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%; margin-bottom:20px">
<tr>
<td>Mixin stealth address</td>
<td>blk</td>
<td>mixin</td>
<td>in/out</td>
<td>timestamp</td>
<td>age [y:d:h:m:s]</td>
</tr>
{{#mixins}}
<tr>
<td> - {{mix_idx}}: <a href="/tx/{{mix_tx_hash}}">{{mix_pub_key}}</a></td>
<td>{{mix_blk}}</td>
<td>{{mix_mixin_no}}</td>
<td>{{mix_inputs_no}}/{{mix_outputs_no}}</td>
<td>{{mix_timestamp}}</td>
<td>{{mix_age}}</td>
</tr>
{{/mixins}}
</table>
</td>
</tr>
{{#with_ring_signatures}}
<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>
{{/with_ring_signatures}}
{{/inputs}}
</table>
{{^with_ring_signatures}}
<h5 style="margin-top:1px"><a href="/tx/{{tx_hash}}/1">More details</a></h5>
{{/with_ring_signatures}}
{{#with_ring_signatures}}
<h3>JSON representaiton of tx</h3>
<div class="center">
<code style="white-space: pre-wrap; font-size: 10px">
{{tx_json}}
</code>
</div>
<h5 style="margin-top:1px"><a href="/tx/{{tx_hash}}">Less details</a></h5>
{{/with_ring_signatures}}
</div>
{{/has_inputs}}
</div>
Loading…
Cancel
Save