diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 1d1e7e149..fbb57fe4a 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -133,10 +133,12 @@ #define THREAD_STACK_SIZE 5 * 1024 * 1024 +#define DEFAULT_MIXIN 9 // ring size 10 + #define HF_VERSION_DYNAMIC_FEE 4 #define HF_VERSION_MIN_MIXIN_4 6 #define HF_VERSION_MIN_MIXIN_7 7 -#define HF_VERSION_MIN_MIXIN_9 10 +#define HF_VERSION_MIN_MIXIN_9 9 #define HF_VERSION_ENFORCE_RCT 6 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8 diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index d5d0684b2..3ec67e7e0 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -781,7 +781,7 @@ namespace cryptonote res.status = "Failed"; res.reason = ""; if ((res.low_mixin = tvc.m_low_mixin)) - add_reason(res.reason, "ring size too small"); + add_reason(res.reason, "invalid ring size"); if ((res.double_spend = tvc.m_double_spend)) add_reason(res.reason, "double spend"); if ((res.invalid_input = tvc.m_invalid_input)) diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp index 29020aa57..3e6e55714 100644 --- a/src/rpc/daemon_handler.cpp +++ b/src/rpc/daemon_handler.cpp @@ -344,7 +344,7 @@ namespace rpc if (tvc.m_low_mixin) { - res.error_details = "mixin too low"; + res.error_details = "invalid mixin"; } if (tvc.m_double_spend) { diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index b02809ba5..8ce164703 100755 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -86,10 +86,6 @@ typedef cryptonote::simple_wallet sw; #define EXTENDED_LOGS_FILE "wallet_details.log" -#define DEFAULT_MIX 9 - -#define MIN_RING_SIZE 10 // Used to inform user about min ring size -- does not track actual protocol - #define OUTPUT_EXPORT_FILE_MAGIC "Monero output export\003" #define LOCK_IDLE_SCOPE() \ @@ -1613,50 +1609,6 @@ bool simple_wallet::set_store_tx_info(const std::vector &args/* = s return true; } -bool simple_wallet::set_default_ring_size(const std::vector &args/* = std::vector()*/) -{ - if (m_wallet->watch_only()) - { - fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); - return true; - } - try - { - if (strchr(args[1].c_str(), '-')) - { - fail_msg_writer() << tr("ring size must be an integer >= ") << MIN_RING_SIZE; - return true; - } - uint32_t ring_size = boost::lexical_cast(args[1]); - if (ring_size < MIN_RING_SIZE && ring_size != 0) - { - fail_msg_writer() << tr("ring size must be an integer >= ") << MIN_RING_SIZE; - return true; - } - - if (ring_size != 0 && ring_size != DEFAULT_MIX+1) - message_writer() << tr("WARNING: this is a non default ring size, which may harm your privacy. Default is recommended."); - - const auto pwd_container = get_and_verify_password(); - if (pwd_container) - { - m_wallet->default_mixin(ring_size > 0 ? ring_size - 1 : 0); - m_wallet->rewrite(m_wallet_file, pwd_container->password()); - } - return true; - } - catch(const boost::bad_lexical_cast &) - { - fail_msg_writer() << tr("ring size must be an integer >= ") << MIN_RING_SIZE; - return true; - } - catch(...) - { - fail_msg_writer() << tr("could not change default ring size"); - return true; - } -} - bool simple_wallet::set_default_priority(const std::vector &args/* = std::vector()*/) { int priority = 0; @@ -2051,32 +2003,32 @@ simple_wallet::simple_wallet() tr("Show the blockchain height.")); m_cmd_binder.set_handler("transfer_original", boost::bind(&simple_wallet::transfer, this, _1), - tr("transfer_original [index=[,,...]] [] []
[]"), - tr("Transfer to
using an older transaction building algorithm. If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. is the number of inputs to include for untraceability. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); + tr("transfer_original [index=[,,...]] []
[]"), + tr("Transfer to
using an older transaction building algorithm. If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), - tr("transfer [index=[,,...]] [] []
[]"), - tr("Transfer to
. If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. is the number of inputs to include for untraceability. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); + tr("transfer [index=[,,...]] []
[]"), + tr("Transfer to
. If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), - tr("locked_transfer [index=[,,...]] [] [] []"), - tr("Transfer to
and lock it for (max. 1000000). If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. is the number of inputs to include for untraceability. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); + tr("locked_transfer [index=[,,...]] [] []"), + tr("Transfer to
and lock it for (max. 1000000). If the parameter \"index=[,,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. Multiple payments can be made at once by adding etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with ring_size 1")); m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), - tr("sweep_all [index=[,,...]] [] []
[]"), + tr("sweep_all [index=[,,...]] []
[]"), tr("Send all unlocked balance to an address. If the parameter \"index[,,...]\" is specified, the wallet sweeps outputs received by those address indices. If omitted, the wallet randomly chooses an address index to be used.")); m_cmd_binder.set_handler("sweep_below", boost::bind(&simple_wallet::sweep_below, this, _1), - tr("sweep_below [index=[,,...]] [] []
[]"), + tr("sweep_below [index=[,,...]] []
[]"), tr("Send all unlocked outputs below the threshold to an address.")); m_cmd_binder.set_handler("sweep_single", boost::bind(&simple_wallet::sweep_single, this, _1), - tr("sweep_single [] []
[]"), + tr("sweep_single []
[]"), tr("Send a single output of the given key image to an address without change.")); m_cmd_binder.set_handler("donate", boost::bind(&simple_wallet::donate, this, _1), - tr("donate [index=[,,...]] [] [] []"), + tr("donate [index=[,,...]] [] []"), tr("Donate to the development team (donate.getmonero.org).")); m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), @@ -2144,8 +2096,6 @@ simple_wallet::simple_wallet() " Whether to print detailed information about ring members during confirmation.\n " "store-tx-info <1|0>\n " " Whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference.\n " - "default-ring-size \n " - " Set the default ring size (default and minimum is 10).\n " "auto-refresh <1|0>\n " " Whether to automatically synchronize new blocks from the daemon.\n " "refresh-type \n " @@ -2363,7 +2313,6 @@ bool simple_wallet::set_variable(const std::vector &args) success_msg_writer() << "always-confirm-transfers = " << m_wallet->always_confirm_transfers(); success_msg_writer() << "print-ring-members = " << m_wallet->print_ring_members(); success_msg_writer() << "store-tx-info = " << m_wallet->store_tx_info(); - success_msg_writer() << "default-ring-size = " << (m_wallet->default_mixin() ? m_wallet->default_mixin() + 1 : 0); success_msg_writer() << "auto-refresh = " << m_wallet->auto_refresh(); success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type()); success_msg_writer() << "priority = " << m_wallet->get_default_priority(); @@ -2418,7 +2367,6 @@ bool simple_wallet::set_variable(const std::vector &args) CHECK_SIMPLE_VARIABLE("always-confirm-transfers", set_always_confirm_transfers, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("print-ring-members", set_print_ring_members, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("store-tx-info", set_store_tx_info, tr("0 or 1")); - CHECK_SIMPLE_VARIABLE("default-ring-size", set_default_ring_size, tr("integer >= ") << MIN_RING_SIZE); CHECK_SIMPLE_VARIABLE("auto-refresh", set_auto_refresh, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("refresh-type", set_refresh_type, tr("full (slowest, no assumptions); optimize-coinbase (fast, assumes the whole coinbase is paid to a single address); no-coinbase (fastest, assumes we receive no coinbase transaction), default (same as optimize-coinbase)")); CHECK_SIMPLE_VARIABLE("priority", set_default_priority, tr("0, 1, 2, 3, or 4")); @@ -4341,7 +4289,7 @@ bool simple_wallet::print_ring_members(const std::vector &args_) { -// "transfer [index=[,,...]] [] []
[]" +// "transfer [index=[,,...]] []
[]" if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } if (!try_connect_to_daemon()) return true; @@ -4364,30 +4312,12 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vectoradjust_priority(priority); - size_t fake_outs_count = 0; - if(local_args.size() > 0) { - size_t ring_size; - if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0])) - { - fake_outs_count = m_wallet->default_mixin(); - if (fake_outs_count == 0) - fake_outs_count = DEFAULT_MIX; - } - else if (ring_size == 0) - { - fail_msg_writer() << tr("Ring size must not be 0"); - return true; - } - else - { - fake_outs_count = ring_size - 1; - local_args.erase(local_args.begin()); - } - } + size_t fake_outs_count = DEFAULT_MIXIN; + uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count); - if (adjusted_fake_outs_count > fake_outs_count) + if (adjusted_fake_outs_count != fake_outs_count) { - fail_msg_writer() << (boost::format(tr("ring size %u is too small, minimum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str(); + fail_msg_writer() << (boost::format(tr("ring size %u must be %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str(); return true; } @@ -4850,7 +4780,7 @@ bool simple_wallet::sweep_unmixable(const std::vector &args_) //---------------------------------------------------------------------------------------------------- bool simple_wallet::sweep_main(uint64_t below, const std::vector &args_) { - // sweep_all [index=[,,...]] []
[] + // sweep_all [index=[,,...]]
[] if (args_.size() == 0) { fail_msg_writer() << tr("No address given"); @@ -4877,30 +4807,12 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector &a priority = m_wallet->adjust_priority(priority); - size_t fake_outs_count = 0; - if(local_args.size() > 0) { - size_t ring_size; - if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0])) - { - fake_outs_count = m_wallet->default_mixin(); - if (fake_outs_count == 0) - fake_outs_count = DEFAULT_MIX; - } - else if (ring_size == 0) - { - fail_msg_writer() << tr("Ring size must not be 0"); - return true; - } - else - { - fake_outs_count = ring_size - 1; - local_args.erase(local_args.begin()); - } - } + size_t fake_outs_count = DEFAULT_MIXIN; + uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count); - if (adjusted_fake_outs_count > fake_outs_count) + if (adjusted_fake_outs_count != fake_outs_count) { - fail_msg_writer() << (boost::format(tr("ring size %u is too small, minimum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str(); + fail_msg_writer() << (boost::format(tr("ring size %u must be %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str(); return true; } @@ -5095,21 +5007,7 @@ bool simple_wallet::sweep_single(const std::vector &args_) priority = m_wallet->adjust_priority(priority); - size_t fake_outs_count = 0; - if(local_args.size() > 0) { - size_t ring_size; - if(!epee::string_tools::get_xtype_from_string(ring_size, local_args[0])) - { - fake_outs_count = m_wallet->default_mixin(); - if (fake_outs_count == 0) - fake_outs_count = DEFAULT_MIX; - } - else - { - fake_outs_count = ring_size - 1; - local_args.erase(local_args.begin()); - } - } + size_t fake_outs_count = DEFAULT_MIXIN; std::vector extra; bool payment_id_seen = false; @@ -5144,7 +5042,7 @@ bool simple_wallet::sweep_single(const std::vector &args_) if (local_args.size() != 2) { - fail_msg_writer() << tr("usage: sweep_single [] []
[]"); + fail_msg_writer() << tr("usage: sweep_single []
[]"); return true; } @@ -5312,7 +5210,7 @@ bool simple_wallet::donate(const std::vector &args_) std::vector local_args = args_; if(local_args.empty() || local_args.size() > 5) { - fail_msg_writer() << tr("usage: donate [index=[,,...]] [] [] []"); + fail_msg_writer() << tr("usage: donate [index=[,,...]] [] []"); return true; } std::string amount_str; diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index f65236113..f17d12764 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -119,7 +119,6 @@ namespace cryptonote bool set_always_confirm_transfers(const std::vector &args = std::vector()); bool set_print_ring_members(const std::vector &args = std::vector()); bool set_store_tx_info(const std::vector &args = std::vector()); - bool set_default_ring_size(const std::vector &args = std::vector()); bool set_auto_refresh(const std::vector &args = std::vector()); bool set_refresh_type(const std::vector &args = std::vector()); bool set_confirm_missing_payment_id(const std::vector &args = std::vector()); diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index e1baf5d97..45fab77f6 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -1137,9 +1137,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const // indicates if dst_addr is integrated address (address + payment_id) // TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441) - size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin(); - if (fake_outs_count == 0) - fake_outs_count = DEFAULT_MIXIN; + size_t fake_outs_count = DEFAULT_MIXIN; uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast(priority)); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 7a668073b..711ca8427 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -646,7 +646,6 @@ wallet2::wallet2(network_type nettype, bool restricted): 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), @@ -2583,9 +2582,6 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable value2.SetInt(m_store_tx_info ? 1 :0); json.AddMember("store_tx_info", value2, json.GetAllocator()); - value2.SetUint(m_default_mixin); - json.AddMember("default_mixin", value2, json.GetAllocator()); - value2.SetUint(m_default_priority); json.AddMember("default_priority", value2, json.GetAllocator()); @@ -2706,7 +2702,6 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_ m_multisig_signers.clear(); m_always_confirm_transfers = false; m_print_ring_members = false; - m_default_mixin = 0; m_default_priority = 0; m_auto_refresh = true; m_refresh_type = RefreshType::RefreshDefault; @@ -2787,8 +2782,6 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_ GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_keys, int, Int, false, true); GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_info, int, Int, false, true); m_store_tx_info = ((field_store_tx_keys != 0) || (field_store_tx_info != 0)); - GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_mixin, unsigned int, Uint, false, 0); - m_default_mixin = field_default_mixin; GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_priority, unsigned int, Uint, false, 0); if (field_default_priority_found) { @@ -5344,21 +5337,9 @@ int wallet2::get_fee_algorithm() const //------------------------------------------------------------------------------------------------------------------------------ uint64_t wallet2::adjust_mixin(uint64_t mixin) const { - if (mixin < 9 && use_fork_rules(8, 10)) { - MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 8, using 10"); - mixin = 9; - } - else if (mixin < 7 && use_fork_rules(7, 10)) { - MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 7, using 7"); - mixin = 7; - } - else if (mixin < 4 && use_fork_rules(6, 10)) { - MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 6, using 5"); - mixin = 4; - } - else if (mixin < 2 && use_fork_rules(2, 10)) { - MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 2, using 3"); - mixin = 2; + if (mixin != DEFAULT_MIXIN) { + MWARNING("invalid ring size"); + mixin = DEFAULT_MIXIN; } return mixin; } @@ -8234,14 +8215,14 @@ const wallet2::transfer_details &wallet2::get_transfer_details(size_t idx) const std::vector wallet2::select_available_unmixable_outputs(bool trusted_daemon) { // request all outputs with less than 3 instances - const size_t min_mixin = use_fork_rules(7, 10) ? 6 : use_fork_rules(6, 10) ? 4 : 2; // v6 increases min mixin from 2 to 4, v7 to 6 + const size_t min_mixin = DEFAULT_MIXIN; return select_available_outputs_from_histogram(min_mixin + 1, false, true, false, trusted_daemon); } //---------------------------------------------------------------------------------------------------- std::vector wallet2::select_available_mixable_outputs(bool trusted_daemon) { // request all outputs with at least 3 instances, so we can use mixin 2 with - const size_t min_mixin = use_fork_rules(7, 10) ? 6 : use_fork_rules(6, 10) ? 4 : 2; // v6 increases min mixin from 2 to 4, v7 to 6 + const size_t min_mixin = DEFAULT_MIXIN; return select_available_outputs_from_histogram(min_mixin + 1, true, true, true, trusted_daemon); } //---------------------------------------------------------------------------------------------------- diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 59b450004..01a1b58bf 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -845,8 +845,6 @@ namespace tools void print_ring_members(bool value) { m_print_ring_members = value; } bool store_tx_info() const { return m_store_tx_info; } void store_tx_info(bool store) { m_store_tx_info = store; } - uint32_t default_mixin() const { return m_default_mixin; } - void default_mixin(uint32_t m) { m_default_mixin = m; } uint32_t get_default_priority() const { return m_default_priority; } void set_default_priority(uint32_t p) { m_default_priority = p; } bool auto_refresh() const { return m_auto_refresh; } @@ -1189,7 +1187,6 @@ namespace tools bool m_always_confirm_transfers; bool m_print_ring_members; bool m_store_tx_info; /*!< request txkey to be returned in RPC, and store in the wallet cache file */ - uint32_t m_default_mixin; uint32_t m_default_priority; RefreshType m_refresh_type; bool m_auto_refresh;