diff options
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 22ddb0639..4a7a70b8c 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; @@ -2999,7 +3077,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_) } LOCK_REFRESH_THREAD_SCOPE(); - + // optional in/out selector if (local_args.size() > 0) { if (local_args[0] == "in" || local_args[0] == "incoming") { @@ -3151,6 +3229,7 @@ bool simple_wallet::run() { refresh(std::vector<std::string>()); } + message_writer(epee::log_space::console_color_green, false) << "Background refresh thread started"; return m_cmd_binder.run_handling(std::string("[") + tr("wallet") + " " + addr_start + "]: ", ""); } //---------------------------------------------------------------------------------------------------- |