From 721a03ca77e64bebf9ae382e36dc101b8a017dff Mon Sep 17 00:00:00 2001 From: stoffu Date: Fri, 6 Oct 2017 14:18:16 +0900 Subject: [PATCH 1/4] tx-pusher: support hex string of raw tx --- src/page.h | 117 ++++++++++++++++++++++----------------- src/templates/rawtx.html | 5 +- 2 files changed, 71 insertions(+), 51 deletions(-) diff --git a/src/page.h b/src/page.h index ab3bfa8..8d6cf65 100644 --- a/src/page.h +++ b/src/page.h @@ -813,7 +813,7 @@ namespace xmreg { // get only first no_of_mempool_tx txs mempool_txs = MempoolStatus::get_mempool_txs(no_of_mempool_tx); - no_of_mempool_tx = std::min(no_of_mempool_tx, mempool_txs.size()); + no_of_mempool_tx = std::min(no_of_mempool_tx, mempool_txs.size()); } // total size of mempool in bytes @@ -940,7 +940,7 @@ namespace xmreg cerr << "rpc.get_alt_blocks(atl_blks_hashes) failed" << endl; } - context.emplace("no_alt_blocks", atl_blks_hashes.size()); + context.emplace("no_alt_blocks", (uint64_t)atl_blks_hashes.size()); for (const string& alt_blk_hash: atl_blks_hashes) { @@ -2769,84 +2769,101 @@ namespace xmreg { clean_post_data(raw_tx_data); - string decoded_raw_tx_data = epee::string_encoding::base64_decode(raw_tx_data); - - const size_t magiclen = strlen(SIGNED_TX_PREFIX); - - string data_prefix = xmreg::make_printable(decoded_raw_tx_data.substr(0, magiclen)); - // initalize page template context map mstch::map context { {"testnet" , testnet}, {"have_raw_tx" , true}, {"has_error" , false}, {"error_msg" , string {}}, - {"data_prefix" , data_prefix}, }; - context.emplace("txs", mstch::array{}); // add header and footer string full_page = template_file["pushrawtx"]; add_css_style(context); - if (strncmp(decoded_raw_tx_data.c_str(), SIGNED_TX_PREFIX, magiclen) != 0) + std::vector ptx_vector; + + // first try reading raw_tx_data as a raw hex string + std::string tx_blob; + cryptonote::transaction parsed_tx; + crypto::hash parsed_tx_hash, parsed_tx_prefixt_hash; + if (epee::string_tools::parse_hexstr_to_binbuff(raw_tx_data, tx_blob) && parse_and_validate_tx_from_blob(tx_blob, parsed_tx, parsed_tx_hash, parsed_tx_prefixt_hash)) + { + ptx_vector.push_back({}); + ptx_vector.back().tx = parsed_tx; + } + // if failed, treat raw_tx_data as base64 encoding of signed_monero_tx + else { - string error_msg = fmt::format("The data does not appear to be signed raw tx! Data prefix: {:s}", - data_prefix); + string decoded_raw_tx_data = epee::string_encoding::base64_decode(raw_tx_data); - context["has_error"] = true; - context["error_msg"] = error_msg; + const size_t magiclen = strlen(SIGNED_TX_PREFIX); - return mstch::render(full_page, context); - } + string data_prefix = xmreg::make_printable(decoded_raw_tx_data.substr(0, magiclen)); - if (this->enable_pusher == false) - { - string error_msg = fmt::format( - "Pushing disabled!\n " - "Run explorer with --enable-pusher flag to enable it."); + context["data_prefix"] = data_prefix; - context["has_error"] = true; - context["error_msg"] = error_msg; + if (strncmp(decoded_raw_tx_data.c_str(), SIGNED_TX_PREFIX, magiclen) != 0) + { + string error_msg = fmt::format("The data does not appear to be signed raw tx! Data prefix: {:s}", + data_prefix); - return mstch::render(full_page, context); - } + context["has_error"] = true; + context["error_msg"] = error_msg; - bool r {false}; + return mstch::render(full_page, context); + } - string s = decoded_raw_tx_data.substr(magiclen); + if (this->enable_pusher == false) + { + string error_msg = fmt::format( + "Pushing disabled!\n " + "Run explorer with --enable-pusher flag to enable it."); - ::tools::wallet2::signed_tx_set signed_txs; + context["has_error"] = true; + context["error_msg"] = error_msg; - try - { - std::istringstream iss(s); - boost::archive::portable_binary_iarchive ar(iss); - ar >> signed_txs; + return mstch::render(full_page, context); + } - r = true; - } - catch (...) - { - cerr << "Failed to parse signed tx data " << endl; - } + bool r {false}; + string s = decoded_raw_tx_data.substr(magiclen); - if (!r) - { - string error_msg = fmt::format("Deserialization of signed tx data NOT successful! " - "Maybe its not base64 encoded?"); + ::tools::wallet2::signed_tx_set signed_txs; - context["has_error"] = true; - context["error_msg"] = error_msg; + try + { + std::istringstream iss(s); + boost::archive::portable_binary_iarchive ar(iss); + ar >> signed_txs; - return mstch::render(full_page, context); + r = true; + } + catch (...) + { + cerr << "Failed to parse signed tx data " << endl; + } + + + if (!r) + { + string error_msg = fmt::format("Deserialization of signed tx data NOT successful! " + "Maybe its not base64 encoded?"); + + context["has_error"] = true; + context["error_msg"] = error_msg; + + return mstch::render(full_page, context); + } + + ptx_vector = signed_txs.ptx; } - mstch::array& txs = boost::get(context["txs"]); + context.emplace("txs", mstch::array{}); - std::vector ptx_vector = signed_txs.ptx; + mstch::array& txs = boost::get(context["txs"]); // actually commit the transactions while (!ptx_vector.empty()) @@ -4719,7 +4736,7 @@ namespace xmreg } // maxium five last blocks - no_of_last_blocks = std::min(no_of_last_blocks, 5ul); + no_of_last_blocks = std::min(no_of_last_blocks, 5ul); if (address_str.empty()) { diff --git a/src/templates/rawtx.html b/src/templates/rawtx.html index b7f65ed..47b2a98 100644 --- a/src/templates/rawtx.html +++ b/src/templates/rawtx.html @@ -8,13 +8,16 @@
- Paste base64 encoded, unsigned or signed transaction data here
+ Paste here either a hex string of raw transaction (the tx_blob response in the wallet RPC, or the raw_monero_tx file saved by the wallet CLI with --do-not-relay option specified),
+ or base64 encoded, unsigned or signed transaction data
(In Linux, can get base64 signed raw tx data: base64 signed_monero_tx | xclip -selection clipboard)
(In Windows, can get base64 signed raw tx data: certutil.exe -encode -f signed_monero_tx encoded.txt & type "encoded.txt" | clip)

Note: data is sent to the server, as the calculations are done on the server side
+ Note: "check" does not work for the hex string of raw transaction +
                                        From b202b09c3cf8757178a1607960ff662c1e5e9016 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 9 Oct 2017 12:01:10 +0800 Subject: [PATCH 2/4] dont show '?' when fee is zero. --- src/MempoolStatus.cpp | 2 +- src/page.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index d562401..76c91a6 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -174,7 +174,7 @@ MempoolStatus::read_mempool() last_tx.mixin_no = sum_data[2]; last_tx.num_nonrct_inputs = sum_data[3]; - last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}"); + last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.3f}", false); last_tx.xmr_inputs_str = xmreg::xmr_amount_to_str(last_tx.sum_inputs , "{:0.3f}"); last_tx.xmr_outputs_str = xmreg::xmr_amount_to_str(last_tx.sum_outputs, "{:0.3f}"); last_tx.timestamp_str = xmreg::timestamp_to_str_gm(_tx_info.receive_time); diff --git a/src/page.h b/src/page.h index ab3bfa8..b87108d 100644 --- a/src/page.h +++ b/src/page.h @@ -1141,7 +1141,7 @@ namespace xmreg // add total fees in the block to the context context["sum_fees"] - = xmreg::xmr_amount_to_str(sum_fees, "{:0.6f}"); + = xmreg::xmr_amount_to_str(sum_fees, "{:0.6f}", "0"); // get xmr in the block reward context["blk_reward"] @@ -1623,7 +1623,7 @@ namespace xmreg {"blk_height" , tx_blk_height_str}, {"tx_size" , fmt::format("{:0.4f}", static_cast(txd.size) / 1024.0)}, - {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee)}, + {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", true)}, {"blk_timestamp" , blk_timestamp}, {"delta_time" , age.first}, {"outputs_no" , static_cast(txd.output_pub_keys.size())}, @@ -4946,7 +4946,7 @@ namespace xmreg string emission_blk_no = std::to_string(current_values.blk_no - 1); string emission_coinbase = xmr_amount_to_str(current_values.coinbase, "{:0.3f}"); - string emission_fee = xmr_amount_to_str(current_values.fee, "{:0.3f}"); + string emission_fee = xmr_amount_to_str(current_values.fee, "{:0.3f}", false); j_data = json { {"blk_no" , current_values.blk_no - 1}, @@ -5297,7 +5297,7 @@ namespace xmreg {"tx_blk_height" , tx_blk_height}, {"tx_size" , fmt::format("{:0.4f}", static_cast(txd.size) / 1024.0)}, - {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee)}, + {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", false)}, {"tx_version" , static_cast(txd.version)}, {"blk_timestamp" , blk_timestamp}, {"blk_timestamp_uint" , blk.timestamp}, From 6e6d47eeefda8476855bf0975d83a39edfd1f508 Mon Sep 17 00:00:00 2001 From: ajs Date: Tue, 31 Oct 2017 19:06:32 +0200 Subject: [PATCH 3/4] Added Atesti to Clearnet versions --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3058dcb..349a024 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Clearnet versions: - [https://moneroexplorer.pro/](https://moneroexplorer.pro/) - nice looking one, https enabled. - [https://explorer.monero-otc.com/](https://explorer.monero-otc.com/) - https enabled. - [http://monerochain.com/](http://monerochain.com/) - JSON API based, multiple nodes. + - [http://atesti.mooo.com:8081/](http://atesti.mooo.com:8081/) - Proof of Existence built with Monero and IPFS. Clearnet testnet Monero version: From 5ef7ca1412e968fc3b89bf7f90ef7a2203b5d7f3 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 8 Nov 2017 15:51:59 +0800 Subject: [PATCH 4/4] readme updated to Monero v0.11.1.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 349a024..2df5802 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ git clone https://github.com/monero-project/monero cd monero/ # checkout last monero version -git checkout -b last_release v0.11.0.0 +git checkout -b last_release v0.11.1.0 make ```