From 03cb0136955e48d27ace77dc19668c9074c4b1ce Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 20 Nov 2020 00:37:48 +0100 Subject: [PATCH] Seed password implementation: in work --- src/gui/qt-daemon/application/mainwindow.cpp | 3 ++- src/simplewallet/simplewallet.cpp | 9 ++++++++- src/wallet/plain_wallet_api.cpp | 2 +- src/wallet/view_iface.h | 14 +++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index 35114508..b4ae200c 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -1978,7 +1978,8 @@ QString MainWindow::is_valid_restore_wallet_text(const QString& param) { TRY_ENTRY(); LOG_API_TIMING(); - return m_backend.is_valid_brain_restore_data(param.toStdString(), ).c_str(); + PREPARE_ARG_FROM_JSON(view::is_valid_restore_wallet_text_param, rwtp); + return m_backend.is_valid_brain_restore_data(rwtp.seed_phrase, rwtp.seed_password).c_str(); CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index af2c40dd..8724fdac 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -333,8 +333,15 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) return false; } + tools::password_container seed_password_container; + if (!seed_password_container.read_password("Please enter Secure Seed password(leave it blank for a non secured seed):\n")) + { + fail_msg_writer() << "failed to read seed phrase"; + return false; + } + bool looks_like_tracking_seed = restore_seed_container.password().find(':') != std::string::npos; - bool r = restore_wallet(m_restore_wallet, restore_seed_container.password(), pwd_container.password(), looks_like_tracking_seed); + bool r = restore_wallet(m_restore_wallet, restore_seed_container.password(), pwd_container.password(), looks_like_tracking_seed, seed_password_container.password()); CHECK_AND_ASSERT_MES(r, false, "wallet restoring failed"); } else diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 04c2e996..e7984ee7 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -526,7 +526,7 @@ namespace plain_wallet } async_callback = [job_id, rwr]() { - std::string res = restore(rwr.restore_key, rwr.path, rwr.pass, rwr.seed_pass); + std::string res = restore(rwr.seed_phrase, rwr.path, rwr.pass, rwr.seed_pass); put_result(job_id, res); }; } diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index aab421be..1e61b98b 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -272,7 +272,6 @@ public: END_KV_SERIALIZE_MAP() }; - get_smart_wallet_info struct request_get_smart_wallet_info { @@ -443,6 +442,19 @@ public: END_KV_SERIALIZE_MAP() }; + + struct is_valid_restore_wallet_text_param + { + uint64_t seed_phrase; + std::string seed_password; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(seed_phrase) + KV_SERIALIZE(seed_password) + END_KV_SERIALIZE_MAP() + }; + + struct restore_wallet_request { std::string pass;