set static ring size

This commit is contained in:
wowario 2018-05-07 13:05:44 +03:00
parent c0245860d8
commit d00b812953
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111
8 changed files with 34 additions and 156 deletions

View File

@ -133,10 +133,12 @@
#define THREAD_STACK_SIZE 5 * 1024 * 1024 #define THREAD_STACK_SIZE 5 * 1024 * 1024
#define DEFAULT_MIXIN 9 // ring size 10
#define HF_VERSION_DYNAMIC_FEE 4 #define HF_VERSION_DYNAMIC_FEE 4
#define HF_VERSION_MIN_MIXIN_4 6 #define HF_VERSION_MIN_MIXIN_4 6
#define HF_VERSION_MIN_MIXIN_7 7 #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 HF_VERSION_ENFORCE_RCT 6
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8

View File

@ -781,7 +781,7 @@ namespace cryptonote
res.status = "Failed"; res.status = "Failed";
res.reason = ""; res.reason = "";
if ((res.low_mixin = tvc.m_low_mixin)) 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)) if ((res.double_spend = tvc.m_double_spend))
add_reason(res.reason, "double spend"); add_reason(res.reason, "double spend");
if ((res.invalid_input = tvc.m_invalid_input)) if ((res.invalid_input = tvc.m_invalid_input))

View File

@ -344,7 +344,7 @@ namespace rpc
if (tvc.m_low_mixin) if (tvc.m_low_mixin)
{ {
res.error_details = "mixin too low"; res.error_details = "invalid mixin";
} }
if (tvc.m_double_spend) if (tvc.m_double_spend)
{ {

View File

@ -85,10 +85,6 @@ typedef cryptonote::simple_wallet sw;
#define EXTENDED_LOGS_FILE "wallet_details.log" #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 OUTPUT_EXPORT_FILE_MAGIC "Monero output export\003"
#define LOCK_IDLE_SCOPE() \ #define LOCK_IDLE_SCOPE() \
@ -1629,47 +1625,6 @@ bool simple_wallet::set_store_tx_info(const std::vector<std::string> &args/* = s
return true; return true;
} }
bool simple_wallet::set_default_ring_size(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
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<uint32_t>(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;
}
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<std::string> &args/* = std::vector<std::string>()*/) bool simple_wallet::set_default_priority(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{ {
int priority = 0; int priority = 0;
@ -2042,32 +1997,32 @@ simple_wallet::simple_wallet()
tr("Show the blockchain height.")); tr("Show the blockchain height."));
m_cmd_binder.set_handler("transfer_original", m_cmd_binder.set_handler("transfer_original",
boost::bind(&simple_wallet::transfer, this, _1), boost::bind(&simple_wallet::transfer, this, _1),
tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"), tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] <address> <amount> [<payment_id>]"),
tr("Transfer <amount> to <address> using an older transaction building algorithm. If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); tr("Transfer <amount> to <address> using an older transaction building algorithm. If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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 <address_2> <amount_2> etcetera (before the payment ID, if it's included)"));
m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1),
tr("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"), tr("transfer [index=<N1>[,<N2>,...]] [<priority>] <address> <amount> [<payment_id>]"),
tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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 <address_2> <amount_2> etcetera (before the payment ID, if it's included)"));
m_cmd_binder.set_handler("locked_transfer", m_cmd_binder.set_handler("locked_transfer",
boost::bind(&simple_wallet::locked_transfer, this, _1), boost::bind(&simple_wallet::locked_transfer, this, _1),
tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <addr> <amount> <lockblocks> [<payment_id>]"), tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] <addr> <amount> <lockblocks> [<payment_id>]"),
tr("Transfer <amount> to <address> and lock it for <lockblocks> (max. 1000000). If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); tr("Transfer <amount> to <address> and lock it for <lockblocks> (max. 1000000). If the parameter \"index=<N1>[,<N2>,...]\" 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. <priority> 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 <address_2> <amount_2> etcetera (before the payment ID, if it's included)"));
m_cmd_binder.set_handler("sweep_unmixable", m_cmd_binder.set_handler("sweep_unmixable",
boost::bind(&simple_wallet::sweep_unmixable, this, _1), boost::bind(&simple_wallet::sweep_unmixable, this, _1),
tr("Send all unmixable outputs to yourself with ring_size 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), m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1),
tr("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>]"), tr("sweep_all [index=<N1>[,<N2>,...]] [<priority>] <address> [<payment_id>]"),
tr("Send all unlocked balance to an address. If the parameter \"index<N1>[,<N2>,...]\" is specified, the wallet sweeps outputs received by those address indices. If omitted, the wallet randomly chooses an address index to be used.")); tr("Send all unlocked balance to an address. If the parameter \"index<N1>[,<N2>,...]\" 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", m_cmd_binder.set_handler("sweep_below",
boost::bind(&simple_wallet::sweep_below, this, _1), boost::bind(&simple_wallet::sweep_below, this, _1),
tr("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>]"), tr("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] <address> [<payment_id>]"),
tr("Send all unlocked outputs below the threshold to an address.")); tr("Send all unlocked outputs below the threshold to an address."));
m_cmd_binder.set_handler("sweep_single", m_cmd_binder.set_handler("sweep_single",
boost::bind(&simple_wallet::sweep_single, this, _1), boost::bind(&simple_wallet::sweep_single, this, _1),
tr("sweep_single [<priority>] [<ring_size>] <key_image> <address> [<payment_id>]"), tr("sweep_single [<priority>] <key_image> <address> [<payment_id>]"),
tr("Send a single output of the given key image to an address without change.")); tr("Send a single output of the given key image to an address without change."));
m_cmd_binder.set_handler("donate", m_cmd_binder.set_handler("donate",
boost::bind(&simple_wallet::donate, this, _1), boost::bind(&simple_wallet::donate, this, _1),
tr("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id>]"), tr("donate [index=<N1>[,<N2>,...]] [<priority>] <amount> [<payment_id>]"),
tr("Donate <amount> to the development team (donate.getmonero.org).")); tr("Donate <amount> to the development team (donate.getmonero.org)."));
m_cmd_binder.set_handler("sign_transfer", m_cmd_binder.set_handler("sign_transfer",
boost::bind(&simple_wallet::sign_transfer, this, _1), boost::bind(&simple_wallet::sign_transfer, this, _1),
@ -2135,8 +2090,6 @@ simple_wallet::simple_wallet()
" Whether to print detailed information about ring members during confirmation.\n " " Whether to print detailed information about ring members during confirmation.\n "
"store-tx-info <1|0>\n " "store-tx-info <1|0>\n "
" Whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference.\n " " Whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference.\n "
"default-ring-size <n>\n "
" Set the default ring size (default and minimum is 10).\n "
"auto-refresh <1|0>\n " "auto-refresh <1|0>\n "
" Whether to automatically synchronize new blocks from the daemon.\n " " Whether to automatically synchronize new blocks from the daemon.\n "
"refresh-type <full|optimize-coinbase|no-coinbase|default>\n " "refresh-type <full|optimize-coinbase|no-coinbase|default>\n "
@ -2349,7 +2302,6 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
success_msg_writer() << "always-confirm-transfers = " << m_wallet->always_confirm_transfers(); 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() << "print-ring-members = " << m_wallet->print_ring_members();
success_msg_writer() << "store-tx-info = " << m_wallet->store_tx_info(); 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() << "auto-refresh = " << m_wallet->auto_refresh();
success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type()); success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type());
success_msg_writer() << "priority = " << m_wallet->get_default_priority(); success_msg_writer() << "priority = " << m_wallet->get_default_priority();
@ -2404,7 +2356,6 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
CHECK_SIMPLE_VARIABLE("always-confirm-transfers", set_always_confirm_transfers, tr("0 or 1")); 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("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("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("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("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")); CHECK_SIMPLE_VARIABLE("priority", set_default_priority, tr("0, 1, 2, 3, or 4"));
@ -4272,7 +4223,7 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::string> &args_) bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::string> &args_)
{ {
// "transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]" // "transfer [index=<N1>[,<N2>,...]] [<priority>] <address> <amount> [<payment_id>]"
if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } if (m_wallet->ask_password() && !get_and_verify_password()) { return true; }
if (!try_connect_to_daemon()) if (!try_connect_to_daemon())
return true; return true;
@ -4295,30 +4246,12 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
priority = m_wallet->adjust_priority(priority); priority = m_wallet->adjust_priority(priority);
size_t fake_outs_count = 0; size_t fake_outs_count = DEFAULT_MIXIN;
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());
}
}
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count); 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; return true;
} }
@ -4747,7 +4680,7 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &args_) bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &args_)
{ {
// sweep_all [index=<N1>[,<N2>,...]] [<ring_size>] <address> [<payment_id>] // sweep_all [index=<N1>[,<N2>,...]] <address> [<payment_id>]
if (args_.size() == 0) if (args_.size() == 0)
{ {
fail_msg_writer() << tr("No address given"); fail_msg_writer() << tr("No address given");
@ -4774,30 +4707,12 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
priority = m_wallet->adjust_priority(priority); priority = m_wallet->adjust_priority(priority);
size_t fake_outs_count = 0; size_t fake_outs_count = DEFAULT_MIXIN;
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());
}
}
uint64_t adjusted_fake_outs_count = m_wallet->adjust_mixin(fake_outs_count); 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; return true;
} }
@ -4992,21 +4907,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
priority = m_wallet->adjust_priority(priority); priority = m_wallet->adjust_priority(priority);
size_t fake_outs_count = 0; size_t fake_outs_count = DEFAULT_MIXIN;
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());
}
}
std::vector<uint8_t> extra; std::vector<uint8_t> extra;
bool payment_id_seen = false; bool payment_id_seen = false;
@ -5041,7 +4942,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
if (local_args.size() != 2) if (local_args.size() != 2)
{ {
fail_msg_writer() << tr("usage: sweep_single [<priority>] [<ring_size>] <key_image> <address> [<payment_id>]"); fail_msg_writer() << tr("usage: sweep_single [<priority>] <key_image> <address> [<payment_id>]");
return true; return true;
} }
@ -5209,7 +5110,7 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
std::vector<std::string> local_args = args_; std::vector<std::string> local_args = args_;
if(local_args.empty() || local_args.size() > 5) if(local_args.empty() || local_args.size() > 5)
{ {
fail_msg_writer() << tr("usage: donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id>]"); fail_msg_writer() << tr("usage: donate [index=<N1>[,<N2>,...]] [<priority>] <amount> [<payment_id>]");
return true; return true;
} }
std::string amount_str; std::string amount_str;

View File

@ -119,7 +119,6 @@ namespace cryptonote
bool set_always_confirm_transfers(const std::vector<std::string> &args = std::vector<std::string>()); bool set_always_confirm_transfers(const std::vector<std::string> &args = std::vector<std::string>());
bool set_print_ring_members(const std::vector<std::string> &args = std::vector<std::string>()); bool set_print_ring_members(const std::vector<std::string> &args = std::vector<std::string>());
bool set_store_tx_info(const std::vector<std::string> &args = std::vector<std::string>()); bool set_store_tx_info(const std::vector<std::string> &args = std::vector<std::string>());
bool set_default_ring_size(const std::vector<std::string> &args = std::vector<std::string>());
bool set_auto_refresh(const std::vector<std::string> &args = std::vector<std::string>()); bool set_auto_refresh(const std::vector<std::string> &args = std::vector<std::string>());
bool set_refresh_type(const std::vector<std::string> &args = std::vector<std::string>()); bool set_refresh_type(const std::vector<std::string> &args = std::vector<std::string>());
bool set_confirm_missing_payment_id(const std::vector<std::string> &args = std::vector<std::string>()); bool set_confirm_missing_payment_id(const std::vector<std::string> &args = std::vector<std::string>());

View File

@ -1106,9 +1106,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
// indicates if dst_addr is integrated address (address + payment_id) // indicates if dst_addr is integrated address (address + payment_id)
// TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441) // TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441)
size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin(); size_t fake_outs_count = DEFAULT_MIXIN;
if (fake_outs_count == 0)
fake_outs_count = DEFAULT_MIXIN;
uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority)); uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority));

View File

@ -646,7 +646,6 @@ wallet2::wallet2(network_type nettype, bool restricted):
m_always_confirm_transfers(true), m_always_confirm_transfers(true),
m_print_ring_members(false), m_print_ring_members(false),
m_store_tx_info(true), m_store_tx_info(true),
m_default_mixin(0),
m_default_priority(0), m_default_priority(0),
m_refresh_type(RefreshOptimizeCoinbase), m_refresh_type(RefreshOptimizeCoinbase),
m_auto_refresh(true), m_auto_refresh(true),
@ -2543,9 +2542,6 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable
value2.SetInt(m_store_tx_info ? 1 :0); value2.SetInt(m_store_tx_info ? 1 :0);
json.AddMember("store_tx_info", value2, json.GetAllocator()); 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); value2.SetUint(m_default_priority);
json.AddMember("default_priority", value2, json.GetAllocator()); json.AddMember("default_priority", value2, json.GetAllocator());
@ -2657,7 +2653,6 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
m_multisig_signers.clear(); m_multisig_signers.clear();
m_always_confirm_transfers = false; m_always_confirm_transfers = false;
m_print_ring_members = false; m_print_ring_members = false;
m_default_mixin = 0;
m_default_priority = 0; m_default_priority = 0;
m_auto_refresh = true; m_auto_refresh = true;
m_refresh_type = RefreshType::RefreshDefault; m_refresh_type = RefreshType::RefreshDefault;
@ -2732,8 +2727,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_keys, int, Int, false, true);
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, store_tx_info, 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)); 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); GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_priority, unsigned int, Uint, false, 0);
if (field_default_priority_found) if (field_default_priority_found)
{ {
@ -5266,21 +5259,9 @@ int wallet2::get_fee_algorithm() const
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
uint64_t wallet2::adjust_mixin(uint64_t mixin) const uint64_t wallet2::adjust_mixin(uint64_t mixin) const
{ {
if (mixin < 9 && use_fork_rules(8, 10)) { if (mixin != DEFAULT_MIXIN) {
MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 8, using 10"); MWARNING("invalid ring size");
mixin = 9; mixin = DEFAULT_MIXIN;
}
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;
} }
return mixin; return mixin;
} }
@ -8108,14 +8089,14 @@ const wallet2::transfer_details &wallet2::get_transfer_details(size_t idx) const
std::vector<size_t> wallet2::select_available_unmixable_outputs(bool trusted_daemon) std::vector<size_t> wallet2::select_available_unmixable_outputs(bool trusted_daemon)
{ {
// request all outputs with less than 3 instances // request all outputs with less than 3 instances
const size_t min_mixin = use_fork_rules(8, 10) ? 9 : 2; // v8 increases min mixin from 7 to 9 const size_t min_mixin = DEFAULT_MIXIN;
return select_available_outputs_from_histogram(min_mixin + 1, false, true, false, trusted_daemon); return select_available_outputs_from_histogram(min_mixin + 1, false, true, false, trusted_daemon);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
std::vector<size_t> wallet2::select_available_mixable_outputs(bool trusted_daemon) std::vector<size_t> wallet2::select_available_mixable_outputs(bool trusted_daemon)
{ {
// request all outputs with at least 3 instances, so we can use mixin 2 with // request all outputs with at least 3 instances, so we can use mixin 2 with
const size_t min_mixin = use_fork_rules(8, 10) ? 9 : 2; // v8 increases min mixin from 7 to 9 const size_t min_mixin = DEFAULT_MIXIN;
return select_available_outputs_from_histogram(min_mixin + 1, true, true, true, trusted_daemon); return select_available_outputs_from_histogram(min_mixin + 1, true, true, true, trusted_daemon);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -844,8 +844,6 @@ namespace tools
void print_ring_members(bool value) { m_print_ring_members = value; } void print_ring_members(bool value) { m_print_ring_members = value; }
bool store_tx_info() const { return m_store_tx_info; } bool store_tx_info() const { return m_store_tx_info; }
void store_tx_info(bool store) { m_store_tx_info = store; } 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; } uint32_t get_default_priority() const { return m_default_priority; }
void set_default_priority(uint32_t p) { m_default_priority = p; } void set_default_priority(uint32_t p) { m_default_priority = p; }
bool auto_refresh() const { return m_auto_refresh; } bool auto_refresh() const { return m_auto_refresh; }
@ -1185,7 +1183,6 @@ namespace tools
bool m_always_confirm_transfers; bool m_always_confirm_transfers;
bool m_print_ring_members; bool m_print_ring_members;
bool m_store_tx_info; /*!< request txkey to be returned in RPC, and store in the wallet cache file */ 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; uint32_t m_default_priority;
RefreshType m_refresh_type; RefreshType m_refresh_type;
bool m_auto_refresh; bool m_auto_refresh;