diff --git a/src/rest_server.cpp b/src/rest_server.cpp index dee46da..dd3b842 100644 --- a/src/rest_server.cpp +++ b/src/rest_server.cpp @@ -537,15 +537,15 @@ namespace lws if (!resp) return resp.error(); - if (resp->size_scale == 0 || 1024 < resp->size_scale || resp->fee_mask == 0) + if ((resp->size_scale != 1 && resp->size_scale != 1024) || resp->fee_mask == 0) return {lws::error::bad_daemon_response}; - const std::uint64_t per_byte_fee = - resp->estimated_base_fee / resp->size_scale; - const std::uint64_t per_byte_fee_masked = - ((per_byte_fee + (resp->fee_mask - 1)) / resp->fee_mask) * resp->fee_mask; + const bool use_per_byte_fee = resp->size_scale == 1; + const std::uint64_t base_fee = resp->estimated_base_fee; + const std::uint64_t base_fee_masked = + ((base_fee + (resp->fee_mask - 1)) / resp->fee_mask) * resp->fee_mask; - return response{per_byte_fee_masked, resp->fee_mask, rpc::safe_uint64(received), std::move(unspent), std::move(req.creds.key)}; + return response{base_fee_masked, resp->fee_mask, rpc::safe_uint64(received), std::move(unspent), std::move(req.creds.key), use_per_byte_fee}; } }; diff --git a/src/rpc/light_wallet.cpp b/src/rpc/light_wallet.cpp index 1007136..a410cf9 100644 --- a/src/rpc/light_wallet.cpp +++ b/src/rpc/light_wallet.cpp @@ -294,7 +294,7 @@ namespace lws return expand_outputs{src, self.user_key}; }; wire::object(dest, - WIRE_FIELD_COPY(per_byte_fee), + wire::field(self.use_per_byte_fee ? "per_byte_fee" : "per_kb_fee", self.base_fee), WIRE_FIELD_COPY(fee_mask), WIRE_FIELD_COPY(amount), wire::field("outputs", wire::as_array(std::cref(self.outputs), expand)) diff --git a/src/rpc/light_wallet.h b/src/rpc/light_wallet.h index c38a6f7..06961d6 100644 --- a/src/rpc/light_wallet.h +++ b/src/rpc/light_wallet.h @@ -155,11 +155,12 @@ namespace rpc struct get_unspent_outs_response { get_unspent_outs_response() = delete; - std::uint64_t per_byte_fee; + std::uint64_t base_fee; // either per_byte_fee or per_kb_fee std::uint64_t fee_mask; safe_uint64 amount; std::vector>> outputs; crypto::secret_key user_key; + bool use_per_byte_fee; }; void write_bytes(wire::json_writer&, const get_unspent_outs_response&);