aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crypto/electrum-words.cpp13
-rw-r--r--src/crypto/electrum-words.h3
-rw-r--r--src/simplewallet/simplewallet.cpp15
3 files changed, 23 insertions, 8 deletions
diff --git a/src/crypto/electrum-words.cpp b/src/crypto/electrum-words.cpp
index 5489d5034..a11d287b2 100644
--- a/src/crypto/electrum-words.cpp
+++ b/src/crypto/electrum-words.cpp
@@ -5,6 +5,7 @@
*/
#include <string>
+#include <cassert>
#include <map>
#include <cstdint>
#include <vector>
@@ -55,14 +56,22 @@ namespace crypto
val = w1 + n * ((w2 - w1) % n) + n * n * ((w3 - w2) % n);
- memcpy(&dst.data + i * 4, &val, 4); // copy 4 bytes to position
+ memcpy(dst.data + i * 4, &val, 4); // copy 4 bytes to position
}
+ std::string wlist_copy = words;
if (wlist.size() == 12)
{
- memcpy(&dst.data, &dst.data + 16, 16); // if electrum 12-word seed, duplicate
+ memcpy(dst.data, dst.data + 16, 16); // if electrum 12-word seed, duplicate
+ wlist_copy += ' ';
+ wlist_copy += words;
}
+ std::string back_to_words;
+ bytes_to_words(dst, back_to_words);
+
+ assert(wlist_copy == back_to_words); // sanity check
+
return true;
}
diff --git a/src/crypto/electrum-words.h b/src/crypto/electrum-words.h
index f5f8d1d95..a533299bd 100644
--- a/src/crypto/electrum-words.h
+++ b/src/crypto/electrum-words.h
@@ -5,6 +5,7 @@
*/
#include <string>
+#include <cstdint>
#include <map>
#include "crypto/crypto.h" // for declaration of crypto::secret_key
@@ -18,7 +19,7 @@ namespace crypto
bool words_to_bytes(const std::string& words, crypto::secret_key& dst);
bool bytes_to_words(const crypto::secret_key& src, std::string& words);
- const std::map<std::string, int> wordsMap = {
+ const std::map<std::string,uint32_t> wordsMap = {
{"like", 0},
{"just", 1},
{"love", 2},
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index ef96d7b96..55099199d 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -255,10 +255,15 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
return false;
}
- size_t c = 0;
- if(!m_generate_new.empty()) ++c;
- if(!m_wallet_file.empty()) ++c;
- if (1 != c)
+ if(m_recover)
+ {
+ if (m_generate_new.empty())
+ {
+ fail_msg_writer() << "You must specify a wallet file name to recover to using either --generate-new-wallet=\"name\"";
+ return false;
+ }
+ }
+ else if(!m_generate_new.empty() ^ !m_wallet_file.empty())
{
if(!ask_wallet_create_if_needed())
return false;
@@ -286,7 +291,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
}
- if (!m_generate_new.empty())
+ if (!m_generate_new.empty() || m_recover)
{
// check for recover flag. if present, require electrum word list (only recovery option for now).
if (m_recover)