aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-01-15 12:05:16 +0900
committerstoffu <stoffu@protonmail.ch>2018-01-28 11:04:52 +0900
commit30c44bce0627260134d3606a9a6d0b453aad763d (patch)
tree39880d433f73a72b3250274abee0baf8ffe20159 /src/simplewallet/simplewallet.cpp
parentsimplewallet: bug fix for backlog estimate (diff)
downloadmonero-30c44bce0627260134d3606a9a6d0b453aad763d.tar.xz
wallet: automatically use low priority if safe (no backlog & recent blocks not full)
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 987c8b286..a6cef1bb9 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -1519,6 +1519,19 @@ bool simple_wallet::set_refresh_from_block_height(const std::vector<std::string>
return true;
}
+bool simple_wallet::set_auto_low_priority(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ const auto pwd_container = get_and_verify_password();
+ if (pwd_container)
+ {
+ parse_bool_and_use(args[1], [&](bool r) {
+ m_wallet->auto_low_priority(r);
+ m_wallet->rewrite(m_wallet_file, pwd_container->password());
+ });
+ }
+ return true;
+}
+
bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
if(args.empty())
@@ -1691,7 +1704,9 @@ simple_wallet::simple_wallet()
"confirm-backlog-threshold [n]\n "
" Set a threshold for confirm-backlog to only warn if the transaction backlog is greater than n blocks.\n "
"refresh-from-block-height [n]\n "
- " Set the height before which to ignore blocks."));
+ " Set the height before which to ignore blocks.\n "
+ "auto-low-priority <1|0>\n "
+ " Whether to automatically use the low priority fee level when it's safe to do so."));
m_cmd_binder.set_handler("encrypted_seed",
boost::bind(&simple_wallet::encrypted_seed, this, _1),
tr("Display the encrypted Electrum-style mnemonic seed."));
@@ -1858,6 +1873,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
success_msg_writer() << "confirm-backlog-threshold = " << m_wallet->get_confirm_backlog_threshold();
success_msg_writer() << "confirm-export-overwrite = " << m_wallet->confirm_export_overwrite();
success_msg_writer() << "refresh-from-block-height = " << m_wallet->get_refresh_from_block_height();
+ success_msg_writer() << "auto-low-priority = " << m_wallet->auto_low_priority();
return true;
}
else
@@ -1907,6 +1923,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
CHECK_SIMPLE_VARIABLE("confirm-backlog-threshold", set_confirm_backlog_threshold, tr("unsigned integer"));
CHECK_SIMPLE_VARIABLE("confirm-export-overwrite", set_confirm_export_overwrite, tr("0 or 1"));
CHECK_SIMPLE_VARIABLE("refresh-from-block-height", set_refresh_from_block_height, tr("block height"));
+ CHECK_SIMPLE_VARIABLE("auto-low-priority", set_auto_low_priority, tr("0 or 1"));
}
fail_msg_writer() << tr("set: unrecognized argument(s)");
return true;
@@ -3667,6 +3684,8 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
if (local_args.size() > 0 && parse_priority(local_args[0], priority))
local_args.erase(local_args.begin());
+ priority = m_wallet->adjust_priority(priority);
+
size_t fake_outs_count = 0;
if(local_args.size() > 0) {
size_t ring_size;
@@ -4144,6 +4163,8 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
if (local_args.size() > 0 && parse_priority(local_args[0], priority))
local_args.erase(local_args.begin());
+ priority = m_wallet->adjust_priority(priority);
+
size_t fake_outs_count = 0;
if(local_args.size() > 0) {
size_t ring_size;
@@ -4356,17 +4377,11 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
std::vector<std::string> local_args = args_;
- int priority = 0;
- if(local_args.size() > 0) {
- auto priority_pos = std::find(
- allowed_priority_strings.begin(),
- allowed_priority_strings.end(),
- local_args[0]);
- if(priority_pos != allowed_priority_strings.end()) {
- local_args.erase(local_args.begin());
- priority = std::distance(allowed_priority_strings.begin(), priority_pos);
- }
- }
+ uint32_t priority = 0;
+ if (local_args.size() > 0 && parse_priority(local_args[0], priority))
+ local_args.erase(local_args.begin());
+
+ priority = m_wallet->adjust_priority(priority);
size_t fake_outs_count = 0;
if(local_args.size() > 0) {