From e593fd5fb27f01b8ab4ba0704c7e6fb9794a60f8 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Sun, 20 Jul 2025 03:46:02 -0400 Subject: [PATCH] Add support for dynamic fees over ZMQ (#166) * Add support for dynamic fees over ZMQ * Fix build after upstream change * Fix unit tests --- CMakeLists.txt | 2 +- external/monero | 2 +- src/rest_server.cpp | 1 + src/rpc/light_wallet.cpp | 3 ++- src/rpc/light_wallet.h | 1 + tests/unit/rest.test.cpp | 8 ++++---- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68865cc..92c720f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,7 @@ if (MONERO_BUILD_DIR) PROTOLIB_LIBRARY ) - if (NOT (monero_monero_SOURCE_DIR MATCHES "${MONERO_SOURCE_DIR}(/src/cryptonote_protocol)")) + if (NOT (monero_monero_SOURCE_DIR MATCHES "${MONERO_SOURCE_DIR}")) message(FATAL_ERROR "Invalid Monero source dir - does not appear to match source used for build directory") endif() diff --git a/external/monero b/external/monero index c572e1a..fbd7348 160000 --- a/external/monero +++ b/external/monero @@ -1 +1 @@ -Subproject commit c572e1ad00802fc83b756460838d01436a512750 +Subproject commit fbd7348d8279dc002c31e43d307e1787dc3b40a9 diff --git a/src/rest_server.cpp b/src/rest_server.cpp index b4f1455..c6d0c66 100644 --- a/src/rest_server.cpp +++ b/src/rest_server.cpp @@ -1110,6 +1110,7 @@ namespace lws rpc->fee_mask, rpc::safe_uint64(received), std::move(unspent), + rpc->fees, std::move(req.creds.key) } ); diff --git a/src/rpc/light_wallet.cpp b/src/rpc/light_wallet.cpp index 7200a81..84f60b2 100644 --- a/src/rpc/light_wallet.cpp +++ b/src/rpc/light_wallet.cpp @@ -350,7 +350,8 @@ namespace lws WIRE_FIELD_COPY(per_byte_fee), WIRE_FIELD_COPY(fee_mask), WIRE_FIELD_COPY(amount), - wire::optional_field("outputs", wire::array(boost::adaptors::transform(self.outputs, expand))) + wire::optional_field("outputs", wire::array(boost::adaptors::transform(self.outputs, expand))), + WIRE_FIELD(fees) ); } diff --git a/src/rpc/light_wallet.h b/src/rpc/light_wallet.h index 192d836..14ec348 100644 --- a/src/rpc/light_wallet.h +++ b/src/rpc/light_wallet.h @@ -210,6 +210,7 @@ namespace rpc std::uint64_t fee_mask; safe_uint64 amount; std::vector>> outputs; + std::vector fees; crypto::secret_key user_key; }; void write_bytes(wire::json_writer&, const get_unspent_outs_response&); diff --git a/tests/unit/rest.test.cpp b/tests/unit/rest.test.cpp index ed09a4c..d1cab34 100644 --- a/tests/unit/rest.test.cpp +++ b/tests/unit/rest.test.cpp @@ -73,7 +73,7 @@ namespace return epee::byte_slice{ std::string{ "{\"jsonrpc\":2.0,\"id\":0,\"result\":{" - "\"estimated_base_fee\":10000,\"fee_mask\":1000,\"size_scale\":256,\"hard_fork_version\":16" + "\"estimated_base_fee\":10000,\"fee_mask\":1000,\"size_scale\":256,\"hard_fork_version\":16,\"fees\":[40,41]" "}}" } }; @@ -184,7 +184,7 @@ LWS_CASE("rest_server") message = "{\"address\":\"" + address + "\",\"view_key\":\"" + viewkey + "\",\"amount\":\"0\"}"; response = invoke(client, "/get_unspent_outs", message); - EXPECT(response == "{\"per_byte_fee\":39,\"fee_mask\":1000,\"amount\":\"0\"}"); + EXPECT(response == "{\"per_byte_fee\":39,\"fee_mask\":1000,\"amount\":\"0\",\"fees\":[40,41]}"); } SECTION("One Receive, Zero Spends") @@ -309,7 +309,7 @@ LWS_CASE("rest_server") "\"height\":4000," "\"rct\":\"" + epee::to_hex::string(epee::as_byte_span(ringct_expanded)) + "\"," "\"recipient\":{\"maj_i\":2,\"min_i\":66}}" - "]}" + "],\"fees\":[40,41]}" ); } @@ -467,7 +467,7 @@ LWS_CASE("rest_server") "\"spend_key_images\":[\"" + epee::to_hex::string(epee::as_byte_span(image)) + "\"]," "\"rct\":\"" + epee::to_hex::string(epee::as_byte_span(ringct_expanded)) + "\"," "\"recipient\":{\"maj_i\":2,\"min_i\":66}}" - "]}" + "],\"fees\":[40,41]}" ); }