From 4fce57b9ad000354a872e2be630f194e3d12ea41 Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Fri, 1 Aug 2014 15:40:18 +0200 Subject: added seed command to get deterministic seed. not yet password protected --- src/simplewallet/simplewallet.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 4bb5389e4..5b614c72a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -188,6 +188,16 @@ std::string simple_wallet::get_commands_str() return ss.str(); } +bool simple_wallet::seed(const std::vector &args/* = std::vector()*/) +{ + std::string electrum_words; + crypto::ElectrumWords::bytes_to_words(m_wallet->get_account().get_keys().m_spend_secret_key, electrum_words); + + success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control. You will not be able to view these words again, so it is imperative to make note of them now.\n"; + std::cout << electrum_words << std::endl; + return true; +} + bool simple_wallet::help(const std::vector &args/* = std::vector()*/) { success_msg_writer() << get_commands_str(); @@ -210,6 +220,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), "set_log - Change current log detalization level, is a number 0-4"); m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), "Show current wallet public address"); m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), "Save wallet synchronized data"); + m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), "Get deterministic seed"); m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), "Show this help"); } //---------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From d0c853281959cc6b3d1b05b5b668c39bbeef2b12 Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Sat, 2 Aug 2014 16:53:29 +0200 Subject: remove help text about seed only displayed once --- src/simplewallet/simplewallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 5b614c72a..5e636b68f 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -193,7 +193,7 @@ bool simple_wallet::seed(const std::vector &args/* = std::vectorget_account().get_keys().m_spend_secret_key, electrum_words); - success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control. You will not be able to view these words again, so it is imperative to make note of them now.\n"; + success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; std::cout << electrum_words << std::endl; return true; } @@ -448,7 +448,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas if (!two_random) { - success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control. You will not be able to view these words again, so it is imperative to make note of them now.\n"; + success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; std::cout << electrum_words << std::endl; } success_msg_writer() << "**********************************************************************"; -- cgit v1.2.3 From 6575d4ebe5a4c4a6c8eb6bff16120e08563440bb Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Sat, 2 Aug 2014 18:14:29 +0200 Subject: check its deterministic wallet before printing seed when running the seed command --- src/simplewallet/simplewallet.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 5e636b68f..45dc49bbe 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -46,7 +46,11 @@ #include "version.h" #include "crypto/crypto.h" // for crypto::secret_key definition #include "crypto/electrum-words.h" - +extern "C" +{ +#include "crypto/keccak.h" +#include "crypto/crypto-ops.h" +} #if defined(WIN32) #include #endif @@ -193,8 +197,20 @@ bool simple_wallet::seed(const std::vector &args/* = std::vectorget_account().get_keys().m_spend_secret_key, electrum_words); - success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; - std::cout << electrum_words << std::endl; + crypto::secret_key second; + keccak((uint8_t *)&m_wallet->get_account().get_keys().m_spend_secret_key, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key)); + + sc_reduce32((uint8_t *)&second); + + if (memcmp(second.data,m_wallet->get_account().get_keys().m_view_secret_key.data, sizeof(crypto::secret_key))==0) + { + success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; + std::cout << electrum_words << std::endl; + } + else + { + fail_msg_writer() << "The wallet is non-deterministic. Cannot display seed."; + } return true; } -- cgit v1.2.3 From 2ba77629ad4f23e521fa1ff22d1970d3619c2fa0 Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Sun, 3 Aug 2014 16:58:21 +0200 Subject: refactoring. get seed code in wallet2 --- src/simplewallet/simplewallet.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 45dc49bbe..58706338a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -46,11 +46,7 @@ #include "version.h" #include "crypto/crypto.h" // for crypto::secret_key definition #include "crypto/electrum-words.h" -extern "C" -{ -#include "crypto/keccak.h" -#include "crypto/crypto-ops.h" -} + #if defined(WIN32) #include #endif @@ -195,14 +191,9 @@ std::string simple_wallet::get_commands_str() bool simple_wallet::seed(const std::vector &args/* = std::vector()*/) { std::string electrum_words; - crypto::ElectrumWords::bytes_to_words(m_wallet->get_account().get_keys().m_spend_secret_key, electrum_words); - - crypto::secret_key second; - keccak((uint8_t *)&m_wallet->get_account().get_keys().m_spend_secret_key, sizeof(crypto::secret_key), (uint8_t *)&second, sizeof(crypto::secret_key)); - - sc_reduce32((uint8_t *)&second); + bool success = m_wallet->get_seed(electrum_words); - if (memcmp(second.data,m_wallet->get_account().get_keys().m_view_secret_key.data, sizeof(crypto::secret_key))==0) + if (success) { success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n"; std::cout << electrum_words << std::endl; -- cgit v1.2.3 From da523f30fcd42d920f1246d7823815e86d6748de Mon Sep 17 00:00:00 2001 From: Jakob Lind Date: Tue, 5 Aug 2014 08:53:30 +0200 Subject: added viewkey command to CLI --- src/simplewallet/simplewallet.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 58706338a..960b1be9d 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -188,6 +188,13 @@ std::string simple_wallet::get_commands_str() return ss.str(); } +bool simple_wallet::viewkey(const std::vector &args/* = std::vector()*/) +{ + success_msg_writer() << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl; + + return true; +} + bool simple_wallet::seed(const std::vector &args/* = std::vector()*/) { std::string electrum_words; @@ -227,6 +234,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), "set_log - Change current log detalization level, is a number 0-4"); m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), "Show current wallet public address"); 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("help", boost::bind(&simple_wallet::help, this, _1), "Show this help"); } -- cgit v1.2.3