From a50c4a4fad9856262638210091d7ce72c547d885 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 24 Mar 2017 21:56:58 +0000 Subject: wallet: option to merge destinations With the change from the original transfer method to the new algorithm, payments to the same destination were merged. It seemed like a good idea, optimizing space. However, it is a useful tool for people who want to split large outputs into several smaller ones (ie, service providers making frequent payments, and who do not like a large chunk of their balance being locked for 10 blocks after each payment). Default to off, which is a change from the previous behavior. --- src/wallet/wallet2.cpp | 14 ++++++++++---- src/wallet/wallet2.h | 7 +++++-- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 09df30e66..ed31f34a4 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1927,6 +1927,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p value2.SetInt(cryptonote::get_default_decimal_point()); json.AddMember("default_decimal_point", value2, json.GetAllocator()); + value2.SetInt(m_merge_destinations ? 1 :0); + json.AddMember("merge_destinations", value2, json.GetAllocator()); + // Serialize the JSON object rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); @@ -1997,6 +2000,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa m_ask_password = true; m_min_output_count = 0; m_min_output_value = 0; + m_merge_destinations = false; } else { @@ -2065,6 +2069,8 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa m_min_output_count = field_min_output_count; GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, min_output_value, uint64_t, Uint64, false, 0); m_min_output_value = field_min_output_value; + GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, merge_destinations, int, Int, false, false); + m_merge_destinations = field_merge_destinations; } const cryptonote::account_keys& keys = m_account.get_keys(); @@ -4238,10 +4244,10 @@ std::vector wallet2::create_transactions_2(std::vector::iterator i; i = std::find_if(dsts.begin(), dsts.end(), [&](const cryptonote::tx_destination_entry &d) { return !memcmp (&d.addr, &addr, sizeof(addr)); }); - if (i == dsts.end()) + if (!merge_destinations || i == dsts.end()) dsts.push_back(tx_destination_entry(amount,addr)); else i->amount += amount; @@ -4408,7 +4414,7 @@ std::vector wallet2::create_transactions_2(std::vector wallet2::create_transactions_2(std::vector, password_container> make_new(const boost::program_options::variables_map& vm); - wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_always_confirm_transfers(true), m_print_ring_members(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), m_confirm_missing_payment_id(true), m_ask_password(true), m_min_output_count(0), m_min_output_value(0), m_restricted(restricted), is_old_file_format(false), m_node_rpc_proxy(m_http_client, m_daemon_rpc_mutex) {} + wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_always_confirm_transfers(true), m_print_ring_members(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), m_confirm_missing_payment_id(true), m_ask_password(true), m_min_output_count(0), m_min_output_value(0), m_merge_destinations(false), m_restricted(restricted), is_old_file_format(false), m_node_rpc_proxy(m_http_client, m_daemon_rpc_mutex) {} struct transfer_details { @@ -531,6 +531,8 @@ namespace tools uint32_t get_min_output_count() const { return m_min_output_count; } void set_min_output_value(uint64_t value) { m_min_output_value = value; } uint64_t get_min_output_value() const { return m_min_output_value; } + void merge_destinations(bool merge) { m_merge_destinations = merge; } + bool merge_destinations() const { return m_merge_destinations; } bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const; @@ -689,6 +691,7 @@ namespace tools bool m_ask_password; uint32_t m_min_output_count; uint64_t m_min_output_value; + bool m_merge_destinations; NodeRPCProxy m_node_rpc_proxy; std::unordered_set m_scanned_pool_txs[2]; }; -- cgit v1.2.3