From ca0255e57d37aeafad9c706a6abc554fe68573ec Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 28 Sep 2016 14:37:53 +0800 Subject: [PATCH] checkrawtx.html template started --- src/page.h | 82 ++++++++++++++++- src/templates/checkrawtx.html | 165 ++++++++++++++++++++++++++++++++++ src/templates/rawtx.html | 26 +++--- src/tools.cpp | 37 ++++++++ src/tools.h | 4 + 5 files changed, 298 insertions(+), 16 deletions(-) create mode 100644 src/templates/checkrawtx.html diff --git a/src/page.h b/src/page.h index 4e13213..4b36c5b 100644 --- a/src/page.h +++ b/src/page.h @@ -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(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(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(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); } diff --git a/src/templates/checkrawtx.html b/src/templates/checkrawtx.html new file mode 100644 index 0000000..0484781 --- /dev/null +++ b/src/templates/checkrawtx.html @@ -0,0 +1,165 @@ + + + + + + {{#refresh}} + + {{/refresh}} + Onion Monero Blockchain Explorer + + + + + +
+ +
+

Onion Monero Transaction Pusher

+

(no javascript - no cookies - no web analytics trackers - no images - open sourced)

+
+ +
+

Details of submitted raw tx data

+ unsigned_tx_given: {{unsigned_tx_given}} +
+ {{#txs}} + no_of_destinations: {{no_of_destinations}}
+ + + {{#dest_sources}} + + + + {{/dest_sources}} +
AddressAmount
{{single_dest_source}}{{amount}}
+ Outputs used
+ + Stealth address + {{#outputs}} + + + {{/outputs}} +
Output IndexIs this real output
{{out_index}}{{tx_hash}}
    ctkey: {{ctkey}}
+
+ {{/txs}} +
+ + +
\ No newline at end of file diff --git a/src/templates/rawtx.html b/src/templates/rawtx.html index c6ae2c7..9141b68 100644 --- a/src/templates/rawtx.html +++ b/src/templates/rawtx.html @@ -135,22 +135,24 @@

(no javascript - no cookies - no web analytics trackers - no images - open sourced)

- {{^testnet}} -
-
- Paste base64 encoded, signed transaction data here
- -
- -                     -                     - -
-
+ {{/testnet}} {{#testnet}} {{/testnet}} +
+
+ Paste base64 encoded, signed transaction data here
+ +
+ +                     +                     + +
+
+ + \ No newline at end of file diff --git a/src/tools.cpp b/src/tools.cpp index d217351..b20b3be 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -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; + } + } diff --git a/src/tools.h b/src/tools.h index eeacf05..a4e9a69 100644 --- a/src/tools.h +++ b/src/tools.h @@ -228,6 +228,10 @@ namespace xmreg map parse_crow_post_data(const string& req_body); + + bool + get_dummy_account_keys(account_keys& dummy_keys, bool testnet = false); + } #endif //XMREG01_TOOLS_H