checkrawtx.html template started

master
moneroexamples 8 years ago
parent 2d7f1854f9
commit ca0255e57d

@ -38,6 +38,8 @@
#define TMPL_MY_OUTPUTS TMPL_DIR "/my_outputs.html"
#define TMPL_SEARCH_RESULTS TMPL_DIR "/search_results.html"
#define TMPL_MY_RAWTX TMPL_DIR "/rawtx.html"
#define TMPL_MY_CHECKRAWTX TMPL_DIR "/checkrawtx.html"
namespace xmreg {
@ -1552,6 +1554,13 @@ namespace xmreg {
cout << "UNSIGNED_TX_PREFIX data given" << endl;
}
// initalize page template context map
mstch::map context {
{"testnet" , testnet},
{"unsigned_tx_given" , unsigned_tx_given},
{"txs" , mstch::array{}}
};
if (unsigned_tx_given)
{
::tools::wallet2::unsigned_tx_set exported_txs;
@ -1562,19 +1571,84 @@ namespace xmreg {
exported_txs);
if (r)
{
mstch::array& txs = boost::get<mstch::array>(context["txs"]);
for (const ::tools::wallet2::tx_construction_data& tx_cd:
exported_txs.txes)
{
size_t no_of_destinations = tx_cd.destinations.size();
mstch::map tx_cd_data {
{"no_of_destinations", no_of_destinations},
{"use_rct" , tx_cd.use_rct},
{"dest_sources" , mstch::array{}}
};
mstch::array& dest_sources = boost::get<mstch::array>(tx_cd_data["dest_sources"]);
for (size_t i = 0; i < no_of_destinations; ++i)
{
const tx_destination_entry& tx_dest = tx_cd.destinations.at(i);
const tx_source_entry& tx_source = tx_cd.sources.at(i);
mstch::map single_dest_source {
{"single_dest_source" ,
get_account_address_as_str(testnet, tx_dest.addr)},
{"amount" ,
fmt::format("{:0.12f}", XMR_AMOUNT(tx_dest.amount))},
{"real_output" , tx_source.real_output},
{"real_out_tx_key" , pod_to_hex(tx_source.real_out_tx_key)},
{"real_output_in_tx_index" , tx_source.real_output_in_tx_index},
{"outputs" , mstch::array{}}
};
cout << tx_source.real_output << endl;
cout << tx_source.real_out_tx_key << endl;
cout << tx_source.real_output_in_tx_index << endl;
mstch::array& outputs = boost::get<mstch::array>(single_dest_source["outputs"]);
size_t output_i {0};
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);
mstch::map single_output {
{"out_index" , oe.first},
{"tx_hash" , pod_to_hex(toi.first)},
{"ctkey" , pod_to_hex(oe.second)}
};
outputs.push_back(single_output);
++output_i;
}
dest_sources.push_back(single_dest_source);
}
txs.push_back(tx_cd_data);
}
}
else
{
cout << "deserialization of unsigined tx data NOT sucessful" << endl;
return string("deserialization of unsigined tx data NOT successful. "
cerr << "deserialization of unsigned tx data NOT successful" << endl;
return string("deserialization of unsigned tx data NOT successful. "
"Maybe its not base64 encoded?");
}
}
cout << action << endl;
// read checkrawtx.html
string checkrawtx_html = xmreg::read(TMPL_MY_CHECKRAWTX);
return {};
// add header and footer
string full_page = checkrawtx_html + xmreg::read(TMPL_FOOTER);
// render the page
return mstch::render(full_page, context);
}

@ -0,0 +1,165 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
{{#refresh}}
<meta http-equiv="refresh" content="10">
{{/refresh}}
<title>Onion Monero Blockchain Explorer</title>
<!--<link rel="stylesheet" type="text/css" href="/css/style.css">-->
<style type="text/css">
body {
margin: 0;
padding: 0;
color: white;
background-color: black;
}
h1, h2, h3, h4, h5, h6 {
text-align: center;
}
.center {
margin: auto;
width: 96%;
/*border: 1px solid #73AD21;
padding: 10px;*/
}
tr, li, #pages {
font-family: "Lucida Console", Monaco, monospace;
font-size : 12px;
height: 22px;
}
#pages
{
margin-top: 15px;
}
td {
text-align: center;
}
a:link {
text-decoration: none;
color: white;
}
a:visited {
text-decoration: none;
color: white;
}
a:hover {
text-decoration: underline;
color: white;
}
a:active {
text-decoration: none;
color: white;
}
form {
display: inline-block;
text-align: center;
}
.style-1 input[type="text"] {
padding: 2px;
border: solid 1px #dcdcdc;
transition: box-shadow 0.3s, border 0.3s;
}
.style-1 input[type="text"]:focus,
.style-1 input[type="text"].focus {
border: solid 1px #707070;
box-shadow: 0 0 5px 1px #969696;
}
.tabs {
position: relative;
min-height: 200px; /* This part sucks */
clear: both;
margin: 25px 0;
}
.tab {
float: left;
}
.tab label {
background: black;
padding: 10px;
border: 1px solid #ccc;
margin-left: -1px;
position: relative;
left: 1px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 28px;
left: 0;
background: black;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
}
[type=radio]:checked ~ label {
background: #505050 ;
border-bottom: 1px solid white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
</style>
</head>
<body>
<div>
<div class="center">
<h1 class="center"><a href="/">Onion Monero Transaction Pusher</a></h1>
<h4 style="font-size: 15px; margin: 0px">(no javascript - no cookies - no web analytics trackers - no images - open sourced)</h4>
</div>
<div class="center">
<h3>Details of submitted raw tx data</h3>
unsigned_tx_given: {{unsigned_tx_given}}
<br/>
{{#txs}}
no_of_destinations: {{no_of_destinations}} <br/>
<table class="center" style="width: 80%; margin-top:10px">
<tr><td>Address</td><td>Amount</td></tr>
{{#dest_sources}}
<tr><td>{{single_dest_source}}</td><td>{{amount}}</td></tr>
<tr><td colspan="2">
Outputs used <br/>
<table>
<tr><td>Output Index</td>Stealth address<td>Is this real output</td></tr>
{{#outputs}}
<tr><td>{{out_index}}</td><td><a href="/tx/{{tx_hash}}">{{tx_hash}}</a></td><td></td></tr>
<tr><td colspan="3">&nbsp; &nbsp; ctkey: {{ctkey}}</td></tr>
{{/outputs}}
</table>
</td>
</tr>
{{/dest_sources}}
</table>
{{/txs}}
</div>
</div>

@ -135,8 +135,13 @@
<h4 style="font-size: 15px; margin: 0px">(no javascript - no cookies - no web analytics trackers - no images - open sourced)</h4>
</div>
{{^testnet}}
{{/testnet}}
{{#testnet}}
{{/testnet}}
<div class="center">
<form action="/checkandpush" method="post" style="width:100%; margin-top:15px" class="style-1">
Paste base64 encoded, signed transaction data here<br/>
@ -148,9 +153,6 @@
<input type="submit" name="action" value="push">
</form>
</div>
{{/testnet}}
{{#testnet}}
{{/testnet}}
</div>

@ -737,5 +737,42 @@ namespace xmreg
}
return body;
}
bool
get_dummy_account_keys(account_keys& dummy_keys, bool testnet)
{
secret_key adress_prv_viewkey;
secret_key adress_prv_spendkey;
account_public_address dummy_address;
if (!get_account_address_from_str(dummy_address,
testnet,
"4BAyX63gVQgDqKS1wmqNVHdcCNjq1jooLYCXsKEY9w7VdGh45oZbPLvN7y8oVg2zmnhECkRBXpREWb97KtfAcT6p1UNXm9K"))
{
return false;
}
if (!epee::string_tools::hex_to_pod("f238be69411631f35b76c5a9148b3b7e8327eb41bfd0b396e090aeba40235d01", adress_prv_viewkey))
{
return false;
}
if (!epee::string_tools::hex_to_pod("5db8e1d2c505f888e54aca15b1a365c8814d7deebc1a246690db3bf71324950d", adress_prv_spendkey))
{
return false;
}
dummy_keys = account_keys {
dummy_address,
adress_prv_spendkey,
adress_prv_viewkey
};
return true;
}
}

@ -228,6 +228,10 @@ namespace xmreg
map<std::string, std::string>
parse_crow_post_data(const string& req_body);
bool
get_dummy_account_keys(account_keys& dummy_keys, bool testnet = false);
}
#endif //XMREG01_TOOLS_H

Loading…
Cancel
Save