diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index bc951449..2494f056 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -226,7 +226,6 @@ namespace currency } else { - LOG_ERROR("Invalid seed words count: " << words.size()); return false; } diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index b4ae200c..c2aa378b 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -1879,7 +1879,7 @@ QString MainWindow::get_smart_wallet_info(const QString& param) LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::request_get_smart_wallet_info, wo); PREPARE_RESPONSE(view::get_restore_info_response, ar); - ar.error_code = m_backend.get_wallet_restore_info(wo.wallet_id, ar.response_data.restore_key, wo.seed_password); + ar.error_code = m_backend.get_wallet_restore_info(wo.wallet_id, ar.response_data.seed_phrase, wo.seed_password); return MAKE_RESPONSE(ar); CATCH_ENTRY_FAIL_API_RESPONCE(); } @@ -1973,7 +1973,6 @@ QString MainWindow::open_url_in_browser(const QString& param) CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); } - QString MainWindow::is_valid_restore_wallet_text(const QString& param) { TRY_ENTRY(); @@ -1983,6 +1982,17 @@ QString MainWindow::is_valid_restore_wallet_text(const QString& param) CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); } +QString MainWindow::get_seed_phrase_info(const QString& param) +{ + TRY_ENTRY(); + LOG_API_TIMING(); + PREPARE_ARG_FROM_JSON(view::is_valid_restore_wallet_text_param, rwtp); + PREPARE_RESPONSE(view::seed_phrase_info, ar); + ar.error_code = m_backend.get_seed_phrase_info(rwtp.seed_phrase, rwtp.seed_password, ar.response_data).c_str(); + return MAKE_RESPONSE(ar); + CATCH_ENTRY_FAIL_API_RESPONCE(); +} + void MainWindow::contextMenuEvent(QContextMenuEvent * event) { TRY_ENTRY(); diff --git a/src/gui/qt-daemon/application/mainwindow.h b/src/gui/qt-daemon/application/mainwindow.h index 82f1bfd1..ba9216fc 100644 --- a/src/gui/qt-daemon/application/mainwindow.h +++ b/src/gui/qt-daemon/application/mainwindow.h @@ -137,6 +137,7 @@ public: QString is_autostart_enabled(); QString toggle_autostart(const QString& param); QString is_valid_restore_wallet_text(const QString& param); + QString get_seed_phrase_info(const QString& param); QString print_text(const QString& param); QString print_log(const QString& param); QString set_clipboard(const QString& param); diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index f4ad0ea3..4ebdac4b 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -454,6 +454,18 @@ public: END_KV_SERIALIZE_MAP() }; + struct seed_phrase_info + { + bool syntax_correct; + bool require_password; + bool hash_sum_matched; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(syntax_correct) + KV_SERIALIZE(require_password) + KV_SERIALIZE(hash_sum_matched) + END_KV_SERIALIZE_MAP() + }; struct restore_wallet_request { @@ -615,12 +627,10 @@ public: struct get_restore_info_response { - std::string restore_key; - std::string error_code; + std::string seed_phrase; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(restore_key) - KV_SERIALIZE(error_code) + KV_SERIALIZE(seed_phrase) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 7a1228b5..75813f67 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1081,6 +1081,20 @@ void wallets_manager::subscribe_to_core_events(currency::i_core_event_handler* p } #endif + +std::string wallets_manager::get_seed_phrase_info(const std::string& seed_phrase, const std::string& seed_password, view::seed_phrase_info& result) +{ + //cut the last timestamp word from restore_dats + result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password); + if (result.syntax_correct) + { + currency::account_base acc; + result.hash_sum_matched = acc.restore_from_seed_phrase(seed_phrase, seed_password); + } + return API_RETURN_CODE_OK; +} + + void wallets_manager::get_gui_options(view::gui_options& opt) { opt = m_ui_opt; diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index c0cb2b37..151680d1 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -150,6 +150,7 @@ public: std::string transfer(size_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx); std::string get_config_folder(); std::string is_valid_brain_restore_data(const std::string& seed_phrase, const std::string& seed_password); + std::string get_seed_phrase_info(const std::string& seed_phrase, const std::string& seed_password, view::seed_phrase_info& result); #ifndef MOBILE_WALLET_BUILD void subscribe_to_core_events(currency::i_core_event_handler* pevents_handler); //void unsubscribe_to_core_events();