aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-07-18 22:24:53 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-11 13:38:07 +0000
commit5ffb2ff9b7c301eda5811a939c705f26627c4735 (patch)
treeac1ed0c55f69db9e65ebca9567bf3013e55c3bb6 /src/simplewallet/simplewallet.cpp
parentbulletproofs: a few fixes from the Kudelski review (diff)
downloadmonero-5ffb2ff9b7c301eda5811a939c705f26627c4735.tar.xz
v8: per byte fee, pad bulletproofs, fixed 11 ring size
Diffstat (limited to '')
-rw-r--r--src/simplewallet/simplewallet.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index f5aeabded..bcdf2a43f 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -86,9 +86,9 @@ typedef cryptonote::simple_wallet sw;
#define EXTENDED_LOGS_FILE "wallet_details.log"
-#define DEFAULT_MIX 6
+#define DEFAULT_MIX 10
-#define MIN_RING_SIZE 7 // Used to inform user about min ring size -- does not track actual protocol
+#define MIN_RING_SIZE 11 // Used to inform user about min ring size -- does not track actual protocol
#define LOCK_IDLE_SCOPE() \
bool auto_refresh_enabled = m_auto_refresh_enabled.load(std::memory_order_relaxed); \
@@ -829,21 +829,24 @@ bool simple_wallet::print_fee_info(const std::vector<std::string> &args/* = std:
fail_msg_writer() << tr("Cannot connect to daemon");
return true;
}
- const uint64_t per_kb_fee = m_wallet->get_per_kb_fee();
- const uint64_t typical_size_kb = 13;
- message_writer() << (boost::format(tr("Current fee is %s %s per kB")) % print_money(per_kb_fee) % cryptonote::get_unit(cryptonote::get_default_decimal_point())).str();
+ const bool per_byte = m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE);
+ const uint64_t base_fee = m_wallet->get_base_fee();
+ const char *base = per_byte ? "byte" : "kB";
+ const uint64_t typical_size = per_byte ? 2500 : 13;
+ const uint64_t size_granularity = per_byte ? 1 : 1024;
+ message_writer() << (boost::format(tr("Current fee is %s %s per %s")) % print_money(base_fee) % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % base).str();
std::vector<uint64_t> fees;
for (uint32_t priority = 1; priority <= 4; ++priority)
{
uint64_t mult = m_wallet->get_fee_multiplier(priority);
- fees.push_back(per_kb_fee * typical_size_kb * mult);
+ fees.push_back(base_fee * typical_size * mult);
}
std::vector<std::pair<uint64_t, uint64_t>> blocks;
try
{
- uint64_t base_size = typical_size_kb * 1024;
- blocks = m_wallet->estimate_backlog(base_size, base_size + 1023, fees);
+ uint64_t base_size = typical_size * size_granularity;
+ blocks = m_wallet->estimate_backlog(base_size, base_size + size_granularity - 1, fees);
}
catch (const std::exception &e)
{
@@ -1839,6 +1842,8 @@ bool simple_wallet::set_default_ring_size(const std::vector<std::string> &args/*
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.");
+ else if (ring_size == DEFAULT_MIX)
+ message_writer() << tr("WARNING: from v8, ring size will be fixed and this setting will be ignored.");
const auto pwd_container = get_and_verify_password();
if (pwd_container)
@@ -4704,6 +4709,11 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
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();
return true;
}
+ if (adjusted_fake_outs_count < fake_outs_count)
+ {
+ fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
+ return true;
+ }
const size_t min_args = (transfer_type == TransferLocked) ? 3 : 2;
if(local_args.size() < min_args)
@@ -5228,6 +5238,11 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
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();
return true;
}
+ if (adjusted_fake_outs_count < fake_outs_count)
+ {
+ fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
+ return true;
+ }
uint64_t unlock_block = 0;
if (locked) {
@@ -5466,12 +5481,28 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
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);
+ 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();
+ return true;
+ }
+ if (adjusted_fake_outs_count < fake_outs_count)
+ {
+ fail_msg_writer() << (boost::format(tr("ring size %u is too large, maximum is %u")) % (fake_outs_count+1) % (adjusted_fake_outs_count+1)).str();
+ return true;
+ }
std::vector<uint8_t> extra;
bool payment_id_seen = false;