aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/simplewallet/simplewallet.cpp60
-rw-r--r--src/simplewallet/simplewallet.h12
-rw-r--r--src/version.h.in2
-rw-r--r--src/wallet/wallet2.cpp66
-rw-r--r--src/wallet/wallet2.h5
-rw-r--r--utils/gpg_keys/warptangent.asc52
7 files changed, 188 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index ae3378da2..4e3397230 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ all-release:
release-static:
mkdir -p build/release
- cd build/release && cmake -D STATIC=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
+ cd build/release && cmake -D STATIC=ON -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE)
clean:
@echo "WARNING: Back-up your wallet if it exists within ./build!" ; \
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 61c74449c..d82b1a17d 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -231,6 +231,36 @@ bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<st
return true;
}
+bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ bool success = false;
+ if (!m_wallet->is_deterministic())
+ {
+ fail_msg_writer() << "This wallet is non-deterministic and doesn't have a seed.";
+ return true;
+ }
+ tools::password_container pwd_container;
+ success = pwd_container.read_password();
+ if (!success)
+ {
+ fail_msg_writer() << "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() << "invalid password";
+ return true;
+ }
+
+ std::string mnemonic_language = get_mnemonic_language();
+ m_wallet->set_seed_language(mnemonic_language);
+ 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();
@@ -255,9 +285,39 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), "Save wallet synchronized data");
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), "Get viewkey");
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), "Get deterministic seed");
+ m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), "available options: seed language - Set wallet seed langage");
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), "Show this help");
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::set_variable(const std::vector<std::string> &args)
+{
+ if (args.empty())
+ {
+ fail_msg_writer() << "set: needs an argument. available options: seed";
+ return true;
+ }
+ else
+ {
+ if (args[0] == "seed")
+ {
+ if (args.size() == 1)
+ {
+ fail_msg_writer() << "set seed: needs an argument. available options: language";
+ return true;
+ }
+ else if (args[1] == "language")
+ {
+ std::vector<std::string> local_args = args;
+ local_args.erase(local_args.begin(), local_args.begin()+2);
+ seed_set_language(local_args);
+ return true;
+ }
+ }
+ }
+ fail_msg_writer() << "set: unrecognized argument(s)";
+ return true;
+}
+//----------------------------------------------------------------------------------------------------
bool simple_wallet::set_log(const std::vector<std::string> &args)
{
if(args.size() != 1)
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index ebc85ed17..278df707b 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -81,6 +81,17 @@ namespace cryptonote
bool viewkey(const std::vector<std::string> &args = std::vector<std::string>());
bool seed(const std::vector<std::string> &args = std::vector<std::string>());
+
+ /*!
+ * \brief Sets seed language.
+ *
+ * interactive
+ * - prompts for password so wallet can be rewritten
+ * - calls get_mnemonic_language() which prompts for language
+ *
+ * \return success status
+ */
+ bool seed_set_language(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);
@@ -96,6 +107,7 @@ namespace cryptonote
);
bool print_address(const std::vector<std::string> &args = std::vector<std::string>());
bool save(const std::vector<std::string> &args);
+ bool set_variable(const std::vector<std::string> &args);
bool set_log(const std::vector<std::string> &args);
uint64_t get_daemon_blockchain_height(std::string& err);
diff --git a/src/version.h.in b/src/version.h.in
index a09131cdb..6dd62faf9 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -1,3 +1,3 @@
#define MONERO_VERSION_TAG "@VERSIONTAG@"
-#define MONERO_VERSION "0.8.8.6"
+#define MONERO_VERSION "0.8.8.7"
#define MONERO_VERSION_FULL MONERO_VERSION "-" MONERO_VERSION_TAG
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 2b84cbbf3..1c5ec027c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -571,6 +571,54 @@ void wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
}
/*!
+ * \brief verify password for default wallet keys file.
+ * \param password Password to verify
+ *
+ * for verification only
+ * should not mutate state, unlike load_keys()
+ * can be used prior to rewriting wallet keys file, to ensure user has entered the correct password
+ *
+ */
+bool wallet2::verify_password(const std::string& password)
+{
+ const std::string keys_file_name = m_keys_file;
+ wallet2::keys_file_data keys_file_data;
+ std::string buf;
+ bool r = epee::file_io_utils::load_file_to_string(keys_file_name, buf);
+ THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, keys_file_name);
+
+ // Decrypt the contents
+ r = ::serialization::parse_binary(buf, keys_file_data);
+ THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "internal error: failed to deserialize \"" + keys_file_name + '\"');
+ crypto::chacha8_key key;
+ crypto::generate_chacha8_key(password, key);
+ std::string account_data;
+ account_data.resize(keys_file_data.account_data.size());
+ crypto::chacha8(keys_file_data.account_data.data(), keys_file_data.account_data.size(), key, keys_file_data.iv, &account_data[0]);
+
+ // The contents should be JSON if the wallet follows the new format.
+ rapidjson::Document json;
+ if (json.Parse(account_data.c_str(), keys_file_data.account_data.size()).HasParseError())
+ {
+ // old format before JSON wallet key file format
+ }
+ else
+ {
+ account_data = std::string(json["key_data"].GetString(), json["key_data"].GetString() +
+ json["key_data"].GetStringLength());
+ }
+
+ cryptonote::account_base account_data_check;
+
+ r = epee::serialization::load_t_from_binary(account_data_check, account_data);
+ const cryptonote::account_keys& keys = account_data_check.get_keys();
+
+ r = r && verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
+ r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key);
+ return r;
+}
+
+/*!
* \brief Generates a wallet or restores one.
* \param wallet_ Name of wallet file
* \param password Password of wallet file
@@ -616,11 +664,9 @@ void wallet2::rewrite(const std::string& wallet_name, const std::string& passwor
{
prepare_file_names(wallet_name);
boost::system::error_code ignored_ec;
- THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_not_found, m_wallet_file);
THROW_WALLET_EXCEPTION_IF(!boost::filesystem::exists(m_keys_file, ignored_ec), error::file_not_found, m_keys_file);
bool r = store_keys(m_keys_file, password);
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file);
- store();
}
//----------------------------------------------------------------------------------------------------
void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists)
@@ -691,14 +737,16 @@ void wallet2::load(const std::string& wallet_, const std::string& password)
{
LOG_PRINT_L0("file not found: " << m_wallet_file << ", starting with empty blockchain");
m_account_public_address = m_account.get_keys().m_account_address;
- return;
}
- bool r = tools::unserialize_obj_from_file(*this, m_wallet_file);
- THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, m_wallet_file);
- THROW_WALLET_EXCEPTION_IF(
- m_account_public_address.m_spend_public_key != m_account.get_keys().m_account_address.m_spend_public_key ||
- m_account_public_address.m_view_public_key != m_account.get_keys().m_account_address.m_view_public_key,
- error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
+ else
+ {
+ bool r = tools::unserialize_obj_from_file(*this, m_wallet_file);
+ THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, m_wallet_file);
+ THROW_WALLET_EXCEPTION_IF(
+ m_account_public_address.m_spend_public_key != m_account.get_keys().m_account_address.m_spend_public_key ||
+ m_account_public_address.m_view_public_key != m_account.get_keys().m_account_address.m_view_public_key,
+ error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
+ }
cryptonote::block genesis;
generate_genesis(genesis);
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index e037bf42d..d9b1217c7 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -153,6 +153,11 @@ namespace tools
void rewrite(const std::string& wallet_name, const std::string& password);
void load(const std::string& wallet, const std::string& password);
void store();
+
+ /*!
+ * \brief verifies given password is correct for default wallet keys file
+ */
+ bool verify_password(const std::string& password);
cryptonote::account_base& get_account(){return m_account;}
// upper_transaction_size_limit as defined below is set to
diff --git a/utils/gpg_keys/warptangent.asc b/utils/gpg_keys/warptangent.asc
new file mode 100644
index 000000000..cacd787b6
--- /dev/null
+++ b/utils/gpg_keys/warptangent.asc
@@ -0,0 +1,52 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mQINBFSFIj0BEADMJ+82coHXja8ZCQNhs0uw8xTP0Nu3AFIKrCOZIxNFpJvLugOd
+B6IKg3q4YNa5RjhOwVRNfzGk4HsYlo+Wg+pw0pGI1WEYJMQ+gvNACKxDGfgxtDL6
+SgugYxUQqPxud5V6GagyV56e47hfdK0WLmYGsIORoX8nksIAvHbL+T9OVpcdP87s
+5NLyJBFZrrLR404wunnlr2WTE/3Nmm663sGKI+hb7Xb9G09pr0ba8+f4uYtEycaS
+xEBQbeO9Fs/kt02d2oIeqrxulXBHq9LjhXIjiXpeEXUGd6mJmwenclOnreI04esp
+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