From 16f6785bad8065919109ab23e9b16e4cbf82d96a Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 3 Oct 2016 12:53:30 +0800 Subject: [PATCH] showing signed tx details started --- src/page.h | 63 ++++++-- src/templates/checkrawtx.html | 88 ++++++----- src/templates/partials/tx_details.html | 197 +++++++++++++++++++++++++ 3 files changed, 294 insertions(+), 54 deletions(-) create mode 100644 src/templates/partials/tx_details.html diff --git a/src/page.h b/src/page.h index 67e721f..52ebcb8 100644 --- a/src/page.h +++ b/src/page.h @@ -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 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(context["signed_txs"]).push_back(txd_map); + } + } + map 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; } diff --git a/src/templates/checkrawtx.html b/src/templates/checkrawtx.html index 27639e3..cbe42f6 100644 --- a/src/templates/checkrawtx.html +++ b/src/templates/checkrawtx.html @@ -138,46 +138,58 @@

Details of submitted raw tx data

-

unsigned_tx_given: {{unsigned_tx_given}}

- {{#txs}} -
-

Destination information

-
- {{#dest_infos}} - Send {{dest_amount}} to {{dest_address}}
- {{/dest_infos}} -
-

Outputs selected for this tx (total: {{sum_outputs_amounts}})

- {{#dest_sources}} - - - - - - - - - {{#outputs}} + {{#unsigned_tx_given}} +

unsigned_tx_given: {{unsigned_tx_given}}

+ {{#txs}} +
+

Destination information

+
+ {{#dest_infos}} + Send {{dest_amount}} to {{dest_address}}
+ {{/dest_infos}} +
+

Outputs selected for this tx (total: {{sum_outputs_amounts}})

+ {{#dest_sources}} +
Output IndexStealth addressIs this real outputAge {{age_format}}Amount
- - - {{#is_real}} - - {{/is_real}} - {{^is_real}} - - {{/is_real}} - - + + + + + - - {{/outputs}} -
{{out_index}}{{out_pub_key}}{{is_real}}{{is_real}}{{output_age}}{{output_amount}}Output IndexStealth addressIs this real outputAge {{age_format}}Amount
- {{/dest_sources}} -

Change to be returned to the sender

- Amount: {{change_amount}} -
- {{/txs}} + {{#outputs}} + + {{out_index}} + {{out_pub_key}} + {{#is_real}} + {{is_real}} + {{/is_real}} + {{^is_real}} + {{is_real}} + {{/is_real}} + {{output_age}} + {{output_amount}} + + + {{/outputs}} + + {{/dest_sources}} +

Change to be returned to the sender

+ Amount: {{change_amount}} +
+ {{/txs}} + {{/unsigned_tx_given}} + + {{^unsigned_tx_given}} +

signed_tx_given

+ {{#signed_txs}} + {{>tx_details}} + {{/signed_txs}} + + {{/unsigned_tx_given}} + + diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html new file mode 100644 index 0000000..92d50f8 --- /dev/null +++ b/src/templates/partials/tx_details.html @@ -0,0 +1,197 @@ + +
+ +

Tx hash: {{tx_hash}}

+
Tx public key: {{tx_pub_key}}
+ + + {{#has_payment_id}} +
Payment id: {{payment_id}}
+ {{/has_payment_id}} + + {{#has_payment_id8}} +
Payment id (encrypted): {{payment_id8}}
+ {{/has_payment_id8}} + + + {{#have_prev_hash}} +
Previous tx: {{prev_hash}}
+ {{/have_prev_hash}} + + {{#have_next_hash}} +
Next tx: {{next_hash}}
+ {{/have_next_hash}} + + + + + + + + + + + + + + + + + + + + + + + +
Timestamp: {{blk_timestamp_uint}}Timestamp [UCT]: {{blk_timestamp}}Age [y:d:h:m:s]: {{delta_time}}
Block: {{blk_height}}Fee: {{tx_fee}}Tx size: {{tx_size}} kB
Tx version: {{tx_version}}
Extra: {{extra}}
+ + +

{{outputs_no}} output(s) for total of {{outputs_xmr_sum}} xmr

+
+ + + + + + + {{#outputs}} + + + + + + {{/outputs}} +
stealth addressamountamount idx
{{output_idx}}: {{out_pub_key}}{{amount}}{{amount_idx}} of {{num_outputs}}
+
+ +
+
+ +
+ + +
+

Check which outputs belong to given Moenro address and viewkey

+
+
+
+
+ +
+ +
+
+ +
+ + + +
+

Prove to someone that you send them Monero in this transaction

+
Tx private key can be obtained using get_tx_key + command in monero-wallet-cli command line tool
+
+
+
+
+ +
+
+
+
+ +
+ + + +{{#has_inputs}} +

Inputs' mixins time scale (from {{min_mix_time}} till {{max_mix_time}}; + resolution: {{timescales_scale}} days)

+
+
    + {{#timescales}} +
  • |{{timescale}}|
  • + {{/timescales}} +
+
+ + +

{{inputs_no}} inputs(s) for total of {{inputs_xmr_sum}} xmr

+
+ + {{#inputs}} + + + + + + + + + + {{#with_ring_signatures}} + + + + + + {{/with_ring_signatures}} + + + {{/inputs}} +
key image {{input_idx}}: {{in_key_img}}amount: {{amount}}
+ + + + + + + + + + {{#mixins}} + + + + + + + + + {{/mixins}} +
Mixin stealth addressblkmixinin/outtimestampage [y:d:h:m:s]
- {{mix_idx}}: {{mix_pub_key}}{{mix_blk}}{{mix_mixin_no}}{{mix_inputs_no}}/{{mix_outputs_no}}{{mix_timestamp}}{{mix_age}}
+
+ + + + + {{#ring_sigs}} + + + + {{/ring_sigs}} +
Ring signature
{{ring_sig}}
+
+ + + {{^with_ring_signatures}} +
More details
+ {{/with_ring_signatures}} + {{#with_ring_signatures}} + +

JSON representaiton of tx

+
+ + {{tx_json}} + +
+ +
Less details
+ {{/with_ring_signatures}} + +
+ + {{/has_inputs}} + +