From 8a807753447fa62bcff2374e2ca1146e355e0acc Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 29 Nov 2019 11:42:32 -0500 Subject: [PATCH] replace mixin with ring size --- src/daemon/monero_daemon_model.cpp | 6 +++--- src/daemon/monero_daemon_model.h | 2 +- src/utils/monero_utils.cpp | 1 - src/wallet/monero_wallet.cpp | 20 ++++++++++---------- src/wallet/monero_wallet_model.cpp | 2 -- src/wallet/monero_wallet_model.h | 1 - 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/daemon/monero_daemon_model.cpp b/src/daemon/monero_daemon_model.cpp index cf5ca15..4d565d6 100644 --- a/src/daemon/monero_daemon_model.cpp +++ b/src/daemon/monero_daemon_model.cpp @@ -192,7 +192,7 @@ namespace monero { tgt->m_is_miner_tx = src->m_is_miner_tx; tgt->m_payment_id = src->m_payment_id; tgt->m_fee = src->m_fee; - tgt->m_mixin = src->m_mixin; + tgt->m_ring_size = src->m_ring_size; tgt->m_do_not_relay = src->m_do_not_relay; tgt->m_is_relayed = src->m_is_relayed; tgt->m_is_confirmed = src->m_is_confirmed; @@ -248,7 +248,7 @@ namespace monero { if (m_is_miner_tx != boost::none) node.put("isMinerTx", *m_is_miner_tx); if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id); if (m_fee != boost::none) node.put("fee", *m_fee); - if (m_mixin != boost::none) node.put("mixin", *m_mixin); + if (m_ring_size != boost::none) node.put("ringSize", *m_ring_size); if (m_do_not_relay != boost::none) node.put("doNotRelay", *m_do_not_relay); if (m_is_relayed != boost::none) node.put("isRelayed", *m_is_relayed); if (m_is_confirmed != boost::none) node.put("isConfirmed", *m_is_confirmed); @@ -313,7 +313,7 @@ namespace monero { m_version = gen_utils::reconcile(m_version, other->m_version); m_payment_id = gen_utils::reconcile(m_payment_id, other->m_payment_id); m_fee = gen_utils::reconcile(m_fee, other->m_fee, "tx fee"); - m_mixin = gen_utils::reconcile(m_mixin, other->m_mixin, "tx m_mixin"); + m_ring_size = gen_utils::reconcile(m_ring_size, other->m_ring_size, "tx m_ring_size"); m_is_confirmed = gen_utils::reconcile(m_is_confirmed, other->m_is_confirmed); m_do_not_relay = gen_utils::reconcile(m_do_not_relay, other->m_do_not_relay); m_is_relayed = gen_utils::reconcile(m_is_relayed, other->m_is_relayed); diff --git a/src/daemon/monero_daemon_model.h b/src/daemon/monero_daemon_model.h index 60a2ad0..391d132 100644 --- a/src/daemon/monero_daemon_model.h +++ b/src/daemon/monero_daemon_model.h @@ -170,7 +170,7 @@ namespace monero { boost::optional m_is_miner_tx; boost::optional m_payment_id; boost::optional m_fee; - boost::optional m_mixin; + boost::optional m_ring_size; boost::optional m_do_not_relay; boost::optional m_is_relayed; boost::optional m_is_confirmed; diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index a8d22d6..ca0f94f 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -435,7 +435,6 @@ shared_ptr monero_utils::deserialize_send_request(const str } else if (key == string("paymentId")) send_request->m_payment_id = it->second.data(); else if (key == string("priority")) throw runtime_error("deserialize_send_request() priority not implemented"); - else if (key == string("mixin")) send_request->m_mixin = it->second.get_value(); else if (key == string("ringSize")) send_request->m_ring_size = it->second.get_value(); else if (key == string("fee")) send_request->m_fee = it->second.get_value(); else if (key == string("accountIndex")) send_request->m_account_index = it->second.get_value(); diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index 6548064..5727928 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -1979,7 +1979,7 @@ namespace monero { tx->m_in_tx_pool = !tx->m_do_not_relay.get(); if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true tx->m_num_confirmations = 0; - tx->m_mixin = request.m_mixin; + tx->m_ring_size = request.m_ring_size; tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); tx->m_is_locked = true; if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 @@ -2158,7 +2158,7 @@ namespace monero { tx->m_in_tx_pool = !do_not_relay; if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true tx->m_num_confirmations = 0; - tx->m_mixin = request.m_mixin; + tx->m_ring_size = request.m_ring_size; tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 out_transfer->m_account_index = request.m_account_index; @@ -2210,10 +2210,10 @@ namespace monero { } // create transaction - uint64_t m_mixin = m_w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1); + uint64_t mixin = m_w2->adjust_mixin(request.m_ring_size == boost::none ? 0 : request.m_ring_size.get() - 1); uint32_t priority = m_w2->adjust_priority(request.m_priority == boost::none ? 0 : request.m_priority.get()); - uint64_t m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); - std::vector ptx_vector = m_w2->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, 1, m_mixin, m_unlock_time, priority, extra); + uint64_t unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); + std::vector ptx_vector = m_w2->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, 1, mixin, unlock_time, priority, extra); // validate created transaction if (ptx_vector.empty()) throw runtime_error("No outputs found"); @@ -2273,7 +2273,7 @@ namespace monero { tx->m_in_tx_pool = !tx->m_do_not_relay.get(); if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true tx->m_num_confirmations = 0; - tx->m_mixin = request.m_mixin; + tx->m_ring_size = request.m_ring_size; tx->m_unlock_time = request.m_unlock_time == boost::none ? 0 : request.m_unlock_time.get(); tx->m_is_locked = true; if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 @@ -2359,7 +2359,7 @@ namespace monero { tx->m_in_tx_pool = !tx->m_do_not_relay.get(); if (!tx->m_is_failed.get() && tx->m_is_relayed.get()) tx->m_is_double_spend_seen = false; // TODO: test and handle if true tx->m_num_confirmations = 0; - //tx->m_mixin = request.m_mixin; // TODO: how to get? + //tx->m_ring_size = request.m_ring_size; // TODO: how to get? tx->m_unlock_time = 0; if (tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = static_cast(time(NULL)); // set last relayed timestamp to current time iff relayed // TODO monero core: this should be encapsulated in wallet2 out_transfer->m_destinations[0]->m_amount = *tx_amounts_iter; @@ -2439,7 +2439,7 @@ namespace monero { tx->m_output_sum = 0; tx->m_change_amount = 0; tx->m_num_dummy_outputs = 0; - tx->m_mixin = std::numeric_limits::max() - 1; // smaller ring sizes will overwrite // TODO: remove - 1 when switched to ring size + tx->m_ring_size = std::numeric_limits::max(); // smaller ring sizes will overwrite const tools::wallet2::tx_construction_data &cd = tx_constructions[n]; std::vector tx_extra_fields; @@ -2470,8 +2470,8 @@ namespace monero { { tx->m_input_sum = tx->m_input_sum.get() + cd.sources[s].amount; size_t ring_size = cd.sources[s].outputs.size(); - if (ring_size < tx->m_mixin.get() + 1) - tx->m_mixin = ring_size - 1; // TODO: switch to m_ring_size + if (ring_size < tx->m_ring_size.get()) + tx->m_ring_size = ring_size; } for (size_t d = 0; d < cd.splitted_dsts.size(); ++d) { diff --git a/src/wallet/monero_wallet_model.cpp b/src/wallet/monero_wallet_model.cpp index b60c461..61ebcf1 100644 --- a/src/wallet/monero_wallet_model.cpp +++ b/src/wallet/monero_wallet_model.cpp @@ -683,7 +683,6 @@ namespace monero { } m_payment_id = request.m_payment_id; m_priority = request.m_priority; - m_mixin = request.m_mixin; m_ring_size = request.m_ring_size; m_fee = request.m_fee; m_account_index = request.m_account_index; @@ -707,7 +706,6 @@ namespace monero { if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations)); if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id); if (m_priority != boost::none) node.put("priority", *m_priority); - if (m_mixin != boost::none) node.put("mixin", *m_mixin); if (m_ring_size != boost::none) node.put("ringSize", *m_ring_size); if (m_account_index != boost::none) node.put("accountIndex", *m_account_index); if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices)); diff --git a/src/wallet/monero_wallet_model.h b/src/wallet/monero_wallet_model.h index 7152f4d..513ad44 100644 --- a/src/wallet/monero_wallet_model.h +++ b/src/wallet/monero_wallet_model.h @@ -348,7 +348,6 @@ namespace monero { vector> m_destinations; boost::optional m_payment_id; boost::optional m_priority; - boost::optional m_mixin; boost::optional m_ring_size; boost::optional m_fee; boost::optional m_account_index;