Add support for dynamic fees over ZMQ (#166)

* Add support for dynamic fees over ZMQ
* Fix build after upstream change
* Fix unit tests
This commit is contained in:
Lee *!* Clagett
2025-07-20 03:46:02 -04:00
committed by Lee *!* Clagett
parent b63000d21a
commit e593fd5fb2
6 changed files with 10 additions and 7 deletions

View File

@@ -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()

View File

@@ -1110,6 +1110,7 @@ namespace lws
rpc->fee_mask,
rpc::safe_uint64(received),
std::move(unspent),
rpc->fees,
std::move(req.creds.key)
}
);

View File

@@ -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)
);
}

View File

@@ -210,6 +210,7 @@ namespace rpc
std::uint64_t fee_mask;
safe_uint64 amount;
std::vector<std::pair<db::output, std::vector<crypto::key_image>>> outputs;
std::vector<std::uint64_t> fees;
crypto::secret_key user_key;
};
void write_bytes(wire::json_writer&, const get_unspent_outs_response&);

View File

@@ -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]}"
);
}