diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-12-02 07:25:13 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-12-02 07:25:29 +0200 |
commit | 220832b79155a25dcb0f668b4e72b40b15149e02 (patch) | |
tree | 297651294e261a7dd2753c3dbd1fa4632b8f8f8e | |
parent | Merge pull request #192 (diff) | |
parent | prompt for seed language and error handling (diff) | |
download | monero-220832b79155a25dcb0f668b4e72b40b15149e02.tar.xz |
Merge pull request #187
3dd19c4 prompt for seed language and error handling - "seed" simplewallet command was only displaying seed if wallet was newly generated (warptangent)
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 7 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 13 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 84e134fed..be3c82001 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -207,6 +207,13 @@ bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<std::string>()*/) { std::string electrum_words; + + if (m_wallet->get_seed_language().empty()) + { + std::string mnemonic_language = get_mnemonic_language(); + m_wallet->set_seed_language(mnemonic_language); + } + bool success = m_wallet->get_seed(electrum_words); if (success) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 6c271f037..066b006b4 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -91,6 +91,12 @@ void wallet2::init(const std::string& daemon_address, uint64_t upper_transaction //---------------------------------------------------------------------------------------------------- bool wallet2::get_seed(std::string& electrum_words) { + if (seed_language.empty()) + { + std::cout << "seed_language not set" << std::endl; + return false; + } + crypto::ElectrumWords::bytes_to_words(get_account().get_keys().m_spend_secret_key, electrum_words, seed_language); crypto::secret_key second; @@ -101,6 +107,13 @@ bool wallet2::get_seed(std::string& electrum_words) return memcmp(second.data,get_account().get_keys().m_view_secret_key.data, sizeof(crypto::secret_key)) == 0; } /*! + * \brief Gets the seed language + */ +const std::string wallet2::get_seed_language() +{ + return seed_language; +} +/*! * \brief Sets the seed language * \param language Seed language to set to */ diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index d7693e10d..bcd7ce6f7 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -170,6 +170,10 @@ namespace tools bool get_seed(std::string& electrum_words); /*! + * \brief Gets the seed language + */ + const std::string get_seed_language(); + /*! * \brief Sets the seed language */ void set_seed_language(const std::string &language); |