aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-08-06 16:51:40 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-12 13:56:01 +0100
commit651baaec46840290066be1ffec6e999f7919e445 (patch)
tree2c81df7f9e5dacbc36386e61ec8f190cf32e8a48 /src/wallet
parentMerge pull request #2384 (diff)
downloadmonero-651baaec46840290066be1ffec6e999f7919e445.tar.xz
wallet: add encrypted seed functionality
This uses luigi1111's CN_Add method. See https://xmr.llcoins.net for details.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp14
-rw-r--r--src/wallet/wallet2.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 323a3a7fe..6f5ecc288 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -296,6 +296,13 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
return false;
}
restore_deterministic_wallet = true;
+
+ GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, seed_passphrase, std::string, String, false, std::string());
+ if (field_seed_passphrase_found)
+ {
+ if (!field_seed_passphrase.empty())
+ recovery_key = cryptonote::decrypt_key(recovery_key, field_seed_passphrase);
+ }
}
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, address, std::string, String, false, std::string());
@@ -527,7 +534,7 @@ bool wallet2::is_deterministic() const
return keys_deterministic;
}
//----------------------------------------------------------------------------------------------------
-bool wallet2::get_seed(std::string& electrum_words) const
+bool wallet2::get_seed(std::string& electrum_words, const std::string &passphrase) const
{
bool keys_deterministic = is_deterministic();
if (!keys_deterministic)
@@ -541,7 +548,10 @@ bool wallet2::get_seed(std::string& electrum_words) const
return false;
}
- crypto::ElectrumWords::bytes_to_words(get_account().get_keys().m_spend_secret_key, electrum_words, seed_language);
+ crypto::secret_key key = get_account().get_keys().m_spend_secret_key;
+ if (!passphrase.empty())
+ key = cryptonote::encrypt_key(key, passphrase);
+ crypto::ElectrumWords::bytes_to_words(key, electrum_words, seed_language);
return true;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index adf03abcc..971e98351 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -363,7 +363,7 @@ namespace tools
* \brief Checks if deterministic wallet
*/
bool is_deterministic() const;
- bool get_seed(std::string& electrum_words) const;
+ bool get_seed(std::string& electrum_words, const std::string &passphrase = std::string()) const;
/*!
* \brief Gets the seed language
*/