aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-03-01 22:27:27 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-03-02 19:02:41 +0000
commit2c468dd42989d429ae2ebcd696332a4092b4b4cc (patch)
treefd06417f46dd092d1a892093a5b46126d58e1b43 /src/simplewallet
parentMerge pull request #1798 (diff)
downloadmonero-2c468dd42989d429ae2ebcd696332a4092b4b4cc.tar.xz
allow user I/O in millinero, micronero, nanonero, piconero
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp46
-rw-r--r--src/simplewallet/simplewallet.h1
2 files changed, 46 insertions, 1 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 77681ada0..1267d7d3b 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -590,6 +590,36 @@ bool simple_wallet::set_ask_password(const std::vector<std::string> &args/* = st
return true;
}
+bool simple_wallet::set_unit(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ const std::string &unit = args[1];
+ unsigned int decimal_point = CRYPTONOTE_DISPLAY_DECIMAL_POINT;
+
+ if (unit == "monero")
+ decimal_point = CRYPTONOTE_DISPLAY_DECIMAL_POINT;
+ else if (unit == "millinero")
+ decimal_point = CRYPTONOTE_DISPLAY_DECIMAL_POINT - 3;
+ else if (unit == "micronero")
+ decimal_point = CRYPTONOTE_DISPLAY_DECIMAL_POINT - 6;
+ else if (unit == "nanonero")
+ decimal_point = CRYPTONOTE_DISPLAY_DECIMAL_POINT - 9;
+ else if (unit == "piconero")
+ decimal_point = 0;
+ else
+ {
+ fail_msg_writer() << tr("invalid unit");
+ return true;
+ }
+
+ const auto pwd_container = get_and_verify_password();
+ if (pwd_container)
+ {
+ m_wallet->set_default_decimal_point(decimal_point);
+ 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>()*/)
{
success_msg_writer() << get_commands_str();
@@ -629,7 +659,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; print-ring-members <1|0> - whether to print detailed information about ring members during confirmation; 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 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; priority [1|2|3] - normal/elevated/priority fee; confirm-missing-payment-id <1|0>; ask-password <1|0>"));
+ 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; print-ring-members <1|0> - whether to print detailed information about ring members during confirmation; 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 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; priority [1|2|3] - normal/elevated/priority fee; confirm-missing-payment-id <1|0>; ask-password <1|0>; unit <monero|millinero|micronero|nanonero|piconero> - set default monero (sub-)unit"));
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>"));
@@ -663,6 +693,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
success_msg_writer() << "priority = " << m_wallet->get_default_priority();
success_msg_writer() << "confirm-missing-payment-id = " << m_wallet->confirm_missing_payment_id();
success_msg_writer() << "ask-password = " << m_wallet->ask_password();
+ success_msg_writer() << "unit = " << cryptonote::get_unit(m_wallet->get_default_decimal_point());
return true;
}
else
@@ -798,6 +829,19 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
return true;
}
}
+ else if (args[0] == "unit")
+ {
+ if (args.size() <= 1)
+ {
+ fail_msg_writer() << tr("set unit: needs an argument (monero, millinero, micronero, nanop, piconero)");
+ return true;
+ }
+ else
+ {
+ set_unit(args);
+ return true;
+ }
+ }
}
fail_msg_writer() << tr("set: unrecognized argument(s)");
return true;
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index cd99757ab..ddd8248fe 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -116,6 +116,7 @@ namespace cryptonote
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_ask_password(const std::vector<std::string> &args = std::vector<std::string>());
+ bool set_unit(const std::vector<std::string> &args = std::vector<std::string>());
bool help(const std::vector<std::string> &args = std::vector<std::string>());
bool start_mining(const std::vector<std::string> &args);
bool stop_mining(const std::vector<std::string> &args);