diff --git a/src/page.h b/src/page.h index e07638a..53b36cc 100644 --- a/src/page.h +++ b/src/page.h @@ -5695,17 +5695,29 @@ json_networkinfo() return j_response; } - uint64_t fee_estimated {0}; + uint64_t per_kb_fee_estimated {0}; // get dynamic fee estimate from last 10 blocks - if (!get_dynamic_per_kb_fee_estimate(fee_estimated)) + if (!get_dynamic_per_kb_fee_estimate(per_kb_fee_estimated)) { j_response["status"] = "error"; - j_response["message"] = "Cant get dynamic fee esimate"; + j_response["message"] = "Cant get per kb dynamic fee esimate"; return j_response; } - j_info["fee_per_kb"] = fee_estimated; + uint64_t fee_estimated {0}; + + // get dynamic fee estimate from last 10 blocks + //@todo: make this work +// if (!get_base_fee_estimate(fee_estimated)) +// { +// j_response["status"] = "error"; +// j_response["message"] = "Cant get dynamic fee esimate"; +// return j_response; +// } + + j_info["fee_per_kb"] = per_kb_fee_estimated; + j_info["fee_estimate"] = fee_estimated; j_info["tx_pool_size"] = MempoolStatus::mempool_no.load(); j_info["tx_pool_size_kbytes"] = MempoolStatus::mempool_size.load(); @@ -6836,6 +6848,25 @@ get_dynamic_per_kb_fee_estimate(uint64_t& fee_estimated) return true; } +bool +get_base_fee_estimate(uint64_t& fee_estimated) +{ + + string error_msg; + + if (!rpc.get_base_fee_estimate( + FEE_ESTIMATE_GRACE_BLOCKS, + fee_estimated)) + { + cerr << "rpc.get_base_fee_estimate failed" << endl; + return false; + } + + (void) error_msg; + + return true; +} + bool are_absolute_offsets_good( std::vector const& absolute_offsets, diff --git a/src/rpccalls.cpp b/src/rpccalls.cpp index 71c689f..eecf9c9 100644 --- a/src/rpccalls.cpp +++ b/src/rpccalls.cpp @@ -40,6 +40,33 @@ rpccalls::connect_to_monero_daemon() return m_http_client.connect(timeout_time_ms); } + +bool +rpccalls::get_base_fee_estimate(uint64_t grace_blocks, + uint64_t& fee_estimate) { + + cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req; + cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response res; + + req.grace_blocks = grace_blocks; + + if (!connect_to_monero_daemon()) + { + cerr << "get_base_fee_estimate: not connected to daemon" << endl; + return false; + } + + bool r = epee::net_utils::invoke_http_json( + "/get_fee_estimate", + req, res, m_http_client, timeout_time_ms); + + fee_estimate = res.fee; + + return r; + + +} + uint64_t rpccalls::get_current_height() { diff --git a/src/rpccalls.h b/src/rpccalls.h index 05dce44..093c0da 100644 --- a/src/rpccalls.h +++ b/src/rpccalls.h @@ -105,6 +105,9 @@ public: bool get_network_info(COMMAND_RPC_GET_INFO::response& info); + bool + get_base_fee_estimate(uint64_t grace_blocks, uint64_t& fee_estimate); + bool get_hardfork_info( COMMAND_RPC_HARD_FORK_INFO::response& res); diff --git a/src/tools.cpp b/src/tools.cpp index 0340552..5341445 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -627,8 +627,6 @@ sum_fees_in_txs(const vector& txs) return fees_sum; } - - vector get_ouputs(const transaction& tx) {