From 7453999415b5c6bb2c076bd2364dc8add5b77a1a Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 22 Oct 2018 10:14:15 +0800 Subject: [PATCH] Fees are shown in micromonero now https://github.com/moneroexamples/onion-monero-blockchain-explorer/ issues/151 --- src/MempoolStatus.cpp | 3 ++- src/MempoolStatus.h | 2 ++ src/page.h | 11 +++++++++-- src/templates/block.html | 4 ++-- src/templates/index2.html | 4 ++-- src/templates/mempool.html | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 23a3013..4c18fca 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -177,7 +177,6 @@ MempoolStatus::read_mempool() tx, output_pub_keys, input_key_imgs); - double tx_size = static_cast(_tx_info.blob_size)/1024.0; double payed_for_kB = XMR_AMOUNT(_tx_info.fee) / tx_size; @@ -192,7 +191,9 @@ MempoolStatus::read_mempool() last_tx.num_nonrct_inputs = sum_data[3]; last_tx.fee_str = xmreg::xmr_amount_to_str(_tx_info.fee, "{:0.4f}", false); + last_tx.fee_micro_str = xmreg::xmr_amount_to_str(_tx_info.fee*1.0e6, "{:04.0f}", false); last_tx.payed_for_kB_str = fmt::format("{:0.4f}", payed_for_kB); + last_tx.payed_for_kB_micro_str = fmt::format("{:04.0f}", payed_for_kB*1e6); 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/MempoolStatus.h b/src/MempoolStatus.h index c871445..06e02f9 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -38,7 +38,9 @@ struct MempoolStatus uint64_t mixin_no {0}; string fee_str; + string fee_micro_str; string payed_for_kB_str; + string payed_for_kB_micro_str; string xmr_inputs_str; string xmr_outputs_str; string timestamp_str; diff --git a/src/page.h b/src/page.h index 96d90ae..d66144c 100644 --- a/src/page.h +++ b/src/page.h @@ -244,6 +244,8 @@ struct tx_details string fee_str {"N/A"}; string fee_short_str {"N/A"}; string payed_for_kB_str {""}; + string fee_micro_str {"N/A"}; + string payed_for_kB_micro_str {""}; const double& xmr_amount = XMR_AMOUNT(fee); @@ -258,7 +260,9 @@ struct tx_details mixin_str = std::to_string(mixin_no); fee_str = fmt::format("{:0.6f}", xmr_amount); fee_short_str = fmt::format("{:0.4f}", xmr_amount); + fee_micro_str = fmt::format("{:04.0f}" , xmr_amount * 1e6); payed_for_kB_str = fmt::format("{:0.4f}", payed_for_kB); + payed_for_kB_micro_str = fmt::format("{:04.0f}", payed_for_kB * 1e6); } @@ -268,7 +272,9 @@ struct tx_details {"pub_key" , pod_to_hex(pk)}, {"tx_fee" , fee_str}, {"tx_fee_short" , fee_short_str}, + {"fee_micro" , fee_micro_str}, {"payed_for_kB" , payed_for_kB_str}, + {"payed_for_kB_micro", payed_for_kB_micro_str}, {"sum_inputs" , xmr_amount_to_str(xmr_inputs , "{:0.6f}")}, {"sum_outputs" , xmr_amount_to_str(xmr_outputs, "{:0.6f}")}, {"sum_inputs_short" , xmr_amount_to_str(xmr_inputs , "{:0.3f}")}, @@ -1055,8 +1061,8 @@ mempool(bool add_header_and_footer = false, uint64_t no_of_mempool_tx = 25) {"timestamp" , mempool_tx.timestamp_str}, {"age" , age_str}, {"hash" , pod_to_hex(mempool_tx.tx_hash)}, - {"fee" , mempool_tx.fee_str}, - {"payed_for_kB" , mempool_tx.payed_for_kB_str}, + {"fee" , mempool_tx.fee_micro_str}, + {"payed_for_kB" , mempool_tx.payed_for_kB_micro_str}, {"xmr_inputs" , mempool_tx.xmr_inputs_str}, {"xmr_outputs" , mempool_tx.xmr_outputs_str}, {"no_inputs" , mempool_tx.no_inputs}, @@ -5918,6 +5924,7 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) {"tx_blk_height" , tx_blk_height}, {"tx_size" , fmt::format("{:0.4f}", tx_size)}, {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", false)}, + {"tx_fee_micro" , xmreg::xmr_amount_to_str(txd.fee*1e6, "{:0.4f}", false)}, {"payed_for_kB" , fmt::format("{:0.12f}", payed_for_kB)}, {"tx_version" , static_cast(txd.version)}, {"blk_timestamp" , blk_timestamp}, diff --git a/src/templates/block.html b/src/templates/block.html index 6f1b8ed..0e76988 100644 --- a/src/templates/block.html +++ b/src/templates/block.html @@ -64,7 +64,7 @@ hash outputs - fee + fee [µɱ] ring size in/out size [kB] @@ -74,7 +74,7 @@ {{hash}} {{sum_outputs}} - {{tx_fee}} + {{fee_micro}} {{mixin}} {{no_inputs}}/{{no_outputs}} {{tx_size}} diff --git a/src/templates/index2.html b/src/templates/index2.html index 0b74d10..9c8608c 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -81,7 +81,7 @@ age {{age_format}} size [kB] transaction hash - fee + fee [µɱ] outputs in/out/pID ring size @@ -93,7 +93,7 @@ {{age}} {{blk_size}} {{hash}} - {{tx_fee_short}} + {{fee_micro}} {{sum_outputs_short}} {{no_inputs}}/{{no_outputs}}/{{pID}} {{mixin}} diff --git a/src/templates/mempool.html b/src/templates/mempool.html index df9e2e1..d367d26 100644 --- a/src/templates/mempool.html +++ b/src/templates/mempool.html @@ -8,7 +8,7 @@ age [h:m:s] transaction hash - fee/per_kB + fee/per_kB [µɱ] in/out/pID ring size