aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-22 22:21:30 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-22 22:21:30 +0100
commit945c272f6cc12f128bef15c86b8ef6d44b70b29f (patch)
treec4c6b20d4b58d2296c16fa25a7dfb40ff6228e9f /src/simplewallet/simplewallet.cpp
parentMerge pull request #870 (diff)
downloadmonero-945c272f6cc12f128bef15c86b8ef6d44b70b29f.tar.xz
wallet: add a fee multiplier
Fee can now be multiplied by 2 or 3, if users want to give priority to their transactions. There are only three levels to avoid too much fingerprinting. Default is 1 (minimum fee). The default multiplier can be set by "set fee-multiplier X".
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp80
1 files changed, 79 insertions, 1 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 22ddb0639..2ae42324c 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -485,6 +485,68 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s
}
}
+bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ bool success = false;
+ int fee_multiplier = 0;
+ 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("fee multiplier must be 0, 1, 2, or 3 ");
+ return true;
+ }
+ if (args[1] == "0")
+ {
+ fee_multiplier = 0;
+ }
+ else
+ {
+ fee_multiplier = boost::lexical_cast<int>(args[1]);
+ if (fee_multiplier != 1 && fee_multiplier != 2 && fee_multiplier != 3)
+ {
+ fail_msg_writer() << tr("fee multiplier must be 0, 1, 2, or 3");
+ return true;
+ }
+ }
+
+ tools::password_container pwd_container;
+ success = pwd_container.read_password();
+ if (!success)
+ {
+ fail_msg_writer() << tr("failed to read wallet password");
+ return true;
+ }
+
+ /* verify password before using so user doesn't accidentally set a new password for rewritten wallet */
+ success = m_wallet->verify_password(pwd_container.password());
+ if (!success)
+ {
+ fail_msg_writer() << tr("invalid password");
+ return true;
+ }
+
+ m_wallet->set_default_fee_multiplier(fee_multiplier);
+ m_wallet->rewrite(m_wallet_file, pwd_container.password());
+ return true;
+ }
+ catch(const boost::bad_lexical_cast &)
+ {
+ fail_msg_writer() << tr("fee multiplier must be 0, 1, 2 or 3");
+ return true;
+ }
+ catch(...)
+ {
+ fail_msg_writer() << tr("could not change default fee multiplier");
+ return true;
+ }
+}
+
bool simple_wallet::set_auto_refresh(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
bool success = false;
@@ -587,7 +649,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key"));
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key"));
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed"));
- m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour"));
+ m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; fee-multiplier [1|2|3] - normal/elevated/priority fee"));
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
@@ -609,6 +671,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
success_msg_writer() << "default-mixin = " << m_wallet->default_mixin();
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() << "fee-multiplier = " << m_wallet->get_default_fee_multiplier();
return true;
}
else
@@ -704,6 +767,21 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
return true;
}
}
+ else if (args[0] == "fee-multiplier")
+ {
+ if (args.size() <= 1)
+ {
+ fail_msg_writer() << tr("set fee-multiplier: needs an argument: 0, 1, 2, or 3");
+ return true;
+ }
+ else
+ {
+ std::vector<std::string> local_args = args;
+ local_args.erase(local_args.begin(), local_args.begin()+2);
+ set_default_fee_multiplier(local_args);
+ return true;
+ }
+ }
}
fail_msg_writer() << tr("set: unrecognized argument(s)");
return true;