From 30972db5ad9fd57f5a9bb09309ccff3610bf8d7a Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 12 Oct 2022 18:07:04 +0200 Subject: [PATCH] COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS adaptation and improvements --- src/rpc/core_rpc_server_commands_defs.h | 10 +++++++--- src/wallet/wallet2.cpp | 6 +++--- tests/core_tests/get_random_outs.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 563fd950..f6c87873 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -318,11 +318,13 @@ namespace currency struct request { std::list amounts; - uint64_t outs_count; + uint64_t decoys_count; // how many decoy outputs needed (per amount) + uint64_t height_upper_limit; // all the decoy outputs must be either older than, or the same age as this height bool use_forced_mix_outs; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amounts) - KV_SERIALIZE(outs_count) + KV_SERIALIZE(decoys_count) + KV_SERIALIZE(height_upper_limit) KV_SERIALIZE(use_forced_mix_outs) END_KV_SERIALIZE_MAP() }; @@ -331,7 +333,9 @@ namespace currency struct out_entry { uint64_t global_amount_index; - crypto::public_key out_key; + crypto::public_key stealth_address; + crypto::public_key concealing_point; + crypto::public_key amount_commitment; }; #pragma pack(pop) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index c541170b..1147660a 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4731,7 +4731,7 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count, std::vector scanty_outs; for(COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount& amount_outs : daemon_resp.outs) { - if (amount_outs.outs.size() < req.outs_count) + if (amount_outs.outs.size() < req.decoys_count) { scanty_outs.push_back(amount_outs); } @@ -5980,7 +5980,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public { COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request req = AUTO_VAL_INIT(req); req.use_forced_mix_outs = false; - req.outs_count = fake_outs_count + 1; + req.decoys_count = fake_outs_count + 1; for (uint64_t i : selected_transfers) req.amounts.push_back(m_transfers[i].amount()); diff --git a/tests/core_tests/get_random_outs.cpp b/tests/core_tests/get_random_outs.cpp index 7c5f825d..807ad122 100644 --- a/tests/core_tests/get_random_outs.cpp +++ b/tests/core_tests/get_random_outs.cpp @@ -52,7 +52,7 @@ bool get_random_outs_test::check_get_rand_outs(currency::core& c, size_t ev_inde { currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request req = AUTO_VAL_INIT(req); req.amounts.push_back(m_amount); - req.outs_count = 4; + req.decoys_count = 4; req.use_forced_mix_outs = false; currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response res = AUTO_VAL_INIT(res); c.get_blockchain_storage().get_random_outs_for_amounts(req, res);