diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index ac80a305..b3dd880d 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -60,7 +60,7 @@ namespace currency return m_keys; } //----------------------------------------------------------------- - std::string account_base::get_restore_braindata() const + std::string account_base::get_seed_phrase() const { if (m_keys_seed_binary.empty()) return ""; @@ -87,7 +87,7 @@ namespace currency return keys_seed_text + " " + timestamp_word + " " + auditable_flag_and_checksum_word; } //----------------------------------------------------------------- - std::string account_base::get_awo_blob() const + std::string account_base::get_tracking_seed() const { return get_public_address_str() + ":" + epee::string_tools::pod_to_hex(m_keys.view_secret_key) + @@ -104,7 +104,7 @@ namespace currency return true; } //----------------------------------------------------------------- - bool account_base::restore_from_braindata(const std::string& seed_phrase) + bool account_base::restore_from_seed_phrase(const std::string& seed_phrase) { //cut the last timestamp word from restore_dats std::list words; @@ -169,10 +169,10 @@ namespace currency return true; } //----------------------------------------------------------------- - bool account_base::restore_from_awo_blob(const std::string& awo_blob) + bool account_base::restore_from_tracking_seed(const std::string& tracking_seed) { set_null(); - bool r = parse_awo_blob(awo_blob, m_keys.account_address, m_keys.view_secret_key, m_creation_timestamp); + bool r = parse_tracking_seed(tracking_seed, m_keys.account_address, m_keys.view_secret_key, m_creation_timestamp); return r; } //----------------------------------------------------------------- diff --git a/src/currency_core/account.h b/src/currency_core/account.h index 52fec46a..606ea74d 100644 --- a/src/currency_core/account.h +++ b/src/currency_core/account.h @@ -53,10 +53,10 @@ namespace currency const account_public_address& get_public_address() const { return m_keys.account_address; }; std::string get_public_address_str() const; - std::string get_restore_braindata() const; - std::string get_awo_blob() const; - bool restore_from_braindata(const std::string& seed_phrase); - bool restore_from_awo_blob(const std::string& awo_blob); + std::string get_seed_phrase() const; + std::string get_tracking_seed() const; + bool restore_from_seed_phrase(const std::string& seed_phrase); + bool restore_from_tracking_seed(const std::string& tracking_seed); uint64_t get_createtime() const { return m_creation_timestamp; } void set_createtime(uint64_t val) { m_creation_timestamp = val; } diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index d70afd21..09bae730 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -313,10 +313,10 @@ namespace currency return string_tools::get_xtype_from_string(amount, str_amount); } //-------------------------------------------------------------------------------- - bool parse_awo_blob(const std::string& awo_blob, account_public_address& address, crypto::secret_key& view_sec_key, uint64_t& creation_timestamp) + bool parse_tracking_seed(const std::string& tracking_seed, account_public_address& address, crypto::secret_key& view_sec_key, uint64_t& creation_timestamp) { std::vector parts; - boost::split(parts, awo_blob, [](char x){ return x == ':'; } ); + boost::split(parts, tracking_seed, [](char x){ return x == ':'; } ); if (parts.size() != 2 && parts.size() != 3) return false; diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 598b2cb3..c17d3f14 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -239,7 +239,7 @@ namespace currency bool check_inputs_types_supported(const transaction& tx); bool check_outs_valid(const transaction& tx); bool parse_amount(uint64_t& amount, const std::string& str_amount); - bool parse_awo_blob(const std::string& awo_blob, account_public_address& address, crypto::secret_key& view_sec_key, uint64_t& creation_timestamp); + bool parse_tracking_seed(const std::string& tracking_seed, account_public_address& address, crypto::secret_key& view_sec_key, uint64_t& creation_timestamp); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 45c1799f..975d2abe 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -221,7 +221,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), "Get transaction one-time secret key (r) for a given "); - m_cmd_binder.set_handler("awo_blob", boost::bind(&simple_wallet::awo_blob, this, _1), "For auditable wallets: prints auditable watch-only blob for wallet's audit by a third party"); + m_cmd_binder.set_handler("tracking_seed", boost::bind(&simple_wallet::tracking_seed, this, _1), "For auditable wallets: prints auditable watch-only blob for wallet's audit by a third party"); m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), "Save wallet synchronized data"); m_cmd_binder.set_handler("save_watch_only", boost::bind(&simple_wallet::save_watch_only, this, _1), "save_watch_only - save as watch-only wallet file."); @@ -419,7 +419,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas if (m_print_brain_wallet) { - std::cout << "Brain wallet: " << m_wallet->get_account().get_restore_braindata() << std::endl << std::flush; + std::cout << "Seed phrase (keep it in secret): " << m_wallet->get_account().get_seed_phrase() << std::endl << std::flush; } } @@ -439,7 +439,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas return true; } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::restore_wallet(const std::string &wallet_file, const std::string &seed_or_awo_blob, const std::string& password, bool auditable_watch_only) +bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool auditable_watch_only) { m_wallet_file = wallet_file; @@ -450,13 +450,13 @@ bool simple_wallet::restore_wallet(const std::string &wallet_file, const std::st { if (auditable_watch_only) { - m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_awo_blob, true); + m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_tracking_seed, true); message_writer(epee::log_space::console_color_white, true) << "Auditable watch-only wallet restored: " << m_wallet->get_account().get_public_address_str(); } else { // normal wallet - m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_awo_blob, false); + m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_tracking_seed, false); message_writer(epee::log_space::console_color_white, true) << "Wallet restored: " << m_wallet->get_account().get_public_address_str(); std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().view_secret_key) << std::endl << std::flush; } @@ -497,7 +497,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa message_writer(epee::log_space::console_color_white, true) << "Opened" << (m_wallet->is_auditable() ? " auditable" : "") << (m_wallet->is_watch_only() ? " watch-only" : "") << " wallet: " << m_wallet->get_account().get_public_address_str(); if (m_print_brain_wallet) - std::cout << "Brain wallet: " << m_wallet->get_account().get_restore_braindata() << std::endl << std::flush; + std::cout << "Seed phrase (keep it in secret): " << m_wallet->get_account().get_seed_phrase() << std::endl << std::flush; break; } @@ -1373,7 +1373,7 @@ bool simple_wallet::show_seed(const std::vector &args) { success_msg_writer() << "Here's your wallet's seed phrase. Write it down and keep in a safe place."; success_msg_writer(true) << "Anyone who knows the following 26 words can access your wallet:"; - std::cout << m_wallet->get_account().get_restore_braindata() << std::endl << std::flush; + std::cout << m_wallet->get_account().get_seed_phrase() << std::endl << std::flush; return true; } //---------------------------------------------------------------------------------------------------- @@ -1502,7 +1502,7 @@ bool simple_wallet::get_tx_key(const std::vector &args_) } } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::awo_blob(const std::vector &args_) +bool simple_wallet::tracking_seed(const std::vector &args_) { if (!m_wallet->is_auditable()) { @@ -1510,8 +1510,8 @@ bool simple_wallet::awo_blob(const std::vector &args_) return true; } - success_msg_writer() << "Auditable watch-only blob for this wallet is:"; - std::cout << m_wallet->get_account().get_awo_blob() << ENDL; + success_msg_writer() << "Auditable watch-only tracking seed for this wallet is:"; + std::cout << m_wallet->get_account().get_tracking_seed() << ENDL; return true; } //---------------------------------------------------------------------------------------------------- diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 7808333b..47d040a8 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -46,7 +46,7 @@ namespace currency bool new_wallet(const std::string &wallet_file, const std::string& password, bool create_auditable_wallet); bool open_wallet(const std::string &wallet_file, const std::string& password); - bool restore_wallet(const std::string &wallet_file, const std::string &seed_or_awo_blob, const std::string& password, bool auditable_watch_only); + bool restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool auditable_watch_only); bool close_wallet(); bool help(const std::vector &args = std::vector()); @@ -81,7 +81,7 @@ namespace currency bool enable_console_logger(const std::vector &args); bool integrated_address(const std::vector &args); bool get_tx_key(const std::vector &args_); - bool awo_blob(const std::vector &args_); + bool tracking_seed(const std::vector &args_); bool save_watch_only(const std::vector &args); bool sign_transfer(const std::vector &args); bool submit_transfer(const std::vector &args); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index da8a78e6..f1cf1a96 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2294,7 +2294,7 @@ void wallet2::generate(const std::wstring& path, const std::string& pass, bool a store(); } //---------------------------------------------------------------------------------------------------- -void wallet2::restore(const std::wstring& path, const std::string& pass, const std::string& seed_phrase_or_awo_blob, bool auditable_watch_only) +void wallet2::restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool auditable_watch_only) { bool r = false; clear(); @@ -2303,14 +2303,14 @@ void wallet2::restore(const std::wstring& path, const std::string& pass, const s if (auditable_watch_only) { - r = m_account.restore_from_awo_blob(seed_phrase_or_awo_blob); + r = m_account.restore_from_tracking_seed(seed_or_tracking_seed); init_log_prefix(); WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "Could not load auditable watch-only wallet from a given blob: invalid awo blob"); m_watch_only = true; } else { - r = m_account.restore_from_braindata(seed_phrase_or_awo_blob); + r = m_account.restore_from_seed_phrase(seed_or_tracking_seed); init_log_prefix(); THROW_IF_FALSE_WALLET_EX(r, error::wallet_wrong_seed_error, epee::string_encoding::convert_to_ansii(m_wallet_file)); } diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index ef8339dc..743b92bf 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -466,7 +466,7 @@ namespace tools void assign_account(const currency::account_base& acc); void generate(const std::wstring& path, const std::string& password, bool auditable_wallet); - void restore(const std::wstring& path, const std::string& pass, const std::string& seed_phrase_or_awo_blob, bool auditable_watch_only); + void restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool auditable_watch_only); void load(const std::wstring& path, const std::string& password); void store(); void store(const std::wstring& path); diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 6118141b..b1703598 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -196,7 +196,7 @@ namespace tools res.path = epee::string_encoding::convert_to_ansii(m_wallet.get_wallet_path()); res.transfers_count = m_wallet.get_recent_transfers_total_count(); res.transfer_entries_count = m_wallet.get_transfer_entries_count(); - res.seed = m_wallet.get_account().get_restore_braindata(); + res.seed = m_wallet.get_account().get_seed_phrase(); std::map distribution; m_wallet.get_utxo_distribution(distribution); for (const auto& ent : distribution) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index b2b78e8d..042bd9d6 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -856,7 +856,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st w->get_unconfirmed_transfers(owr.recent_history.history); owr.wallet_local_bc_size = w->get_blockchain_current_size(); //workaround for missed fee - owr.seed = w->get_account().get_restore_braindata(); + owr.seed = w->get_account().get_seed_phrase(); break; } catch (const tools::error::file_not_found& /**/) @@ -960,7 +960,7 @@ std::string wallets_manager::generate_wallet(const std::wstring& path, const std { w->generate(path, password, false); w->set_minimum_height(m_last_daemon_height); - owr.seed = w->get_account().get_restore_braindata(); + owr.seed = w->get_account().get_seed_phrase(); } catch (const tools::error::file_exists&) { @@ -1002,16 +1002,16 @@ std::string wallets_manager::is_pos_allowed() else return API_RETURN_CODE_FALSE; } -std::string wallets_manager::is_valid_brain_restore_data(const std::string& brain_text) +std::string wallets_manager::is_valid_brain_restore_data(const std::string& seed_phrase) { currency::account_base acc; - if (acc.restore_from_braindata(brain_text)) + if (acc.restore_from_seed_phrase(seed_phrase)) return API_RETURN_CODE_TRUE; currency::account_public_address addr; crypto::secret_key view_sec_key; uint64_t ts; - if (currency::parse_awo_blob(brain_text, addr, view_sec_key, ts)) + if (currency::parse_tracking_seed(seed_phrase, addr, view_sec_key, ts)) return API_RETURN_CODE_TRUE; return API_RETURN_CODE_FALSE; @@ -1054,7 +1054,7 @@ std::string wallets_manager::restore_wallet(const std::wstring& path, const std: { bool auditable_watch_only = restore_key.find(':') != std::string::npos; w->restore(path, password, restore_key, auditable_watch_only); - owr.seed = w->get_account().get_restore_braindata(); + owr.seed = w->get_account().get_seed_phrase(); } catch (const tools::error::file_exists&) { @@ -1598,7 +1598,7 @@ std::string wallets_manager::get_mining_history(uint64_t wallet_id, tools::walle std::string wallets_manager::get_wallet_restore_info(uint64_t wallet_id, std::string& restore_key) { GET_WALLET_OPT_BY_ID(wallet_id, wo); - restore_key = wo.w->get()->get_account().get_restore_braindata(); + restore_key = wo.w->get()->get_account().get_seed_phrase(); // restore_key = tools::base58::encode(rst_data); return API_RETURN_CODE_OK; } diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index 64501642..dd2797ca 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -148,7 +148,7 @@ public: void toggle_pos_mining(); 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& brain_text); + std::string is_valid_brain_restore_data(const std::string& seed_phrase); #ifndef MOBILE_WALLET_BUILD void subscribe_to_core_events(currency::i_core_event_handler* pevents_handler); //void unsubscribe_to_core_events(); diff --git a/tests/core_tests/checkpoints_tests.cpp b/tests/core_tests/checkpoints_tests.cpp index 3a72115f..c685da27 100644 --- a/tests/core_tests/checkpoints_tests.cpp +++ b/tests/core_tests/checkpoints_tests.cpp @@ -612,8 +612,8 @@ gen_no_attchments_in_coinbase::gen_no_attchments_in_coinbase() // NOTE: This test is made deterministic to be able to correctly set up checkpoint. random_state_test_restorer::reset_random(); // random generator's state was previously stored, will be restore on dtor (see also m_random_state_test_restorer) - bool r = m_miner_acc.restore_from_braindata("battle harsh arrow gain best doubt nose raw protect salty apart tell distant final yeah stubborn true stop shoulder breathe throne problem everyone stranger only"); - CHECK_AND_ASSERT_THROW_MES(r, "gen_no_attchments_in_coinbase: Can't restore account from braindata"); + bool r = m_miner_acc.restore_from_seed_phrase("battle harsh arrow gain best doubt nose raw protect salty apart tell distant final yeah stubborn true stop shoulder breathe throne problem everyone stranger only"); + CHECK_AND_ASSERT_THROW_MES(r, "gen_no_attchments_in_coinbase: Can't restore account from seed phrase"); REGISTER_CALLBACK_METHOD(gen_no_attchments_in_coinbase, c1); REGISTER_CALLBACK_METHOD(gen_no_attchments_in_coinbase, init_config_set_cp); diff --git a/tests/core_tests/hard_fork_2.cpp b/tests/core_tests/hard_fork_2.cpp index db147044..b74b9283 100644 --- a/tests/core_tests/hard_fork_2.cpp +++ b/tests/core_tests/hard_fork_2.cpp @@ -1036,13 +1036,13 @@ bool hard_fork_2_awo_wallets_basic_test::c1(currency::core& c, size // Make sure a wallet, restored from awo blob will has the very same balance // account_base& bob_acc = m_accounts[BOB_ACC_IDX]; - std::string bob_awo_blob = bob_acc.get_awo_blob(); + std::string bob_tracking_seed = bob_acc.get_tracking_seed(); std::shared_ptr bob_wlt_awo_restored = std::make_shared(); boost::filesystem::remove(bob_wo_restored_filename, ec); - bob_wlt_awo_restored->restore(bob_wo_restored_filename, "", bob_awo_blob, true); + bob_wlt_awo_restored->restore(bob_wo_restored_filename, "", bob_tracking_seed, true); bob_wlt_awo_restored->set_core_runtime_config(c.get_blockchain_storage().get_core_runtime_config()); bob_wlt_awo_restored->set_core_proxy(m_core_proxy); @@ -1073,7 +1073,7 @@ bool hard_fork_2_awo_wallets_basic_test::c1(currency::core& c, size // Restore Bob wallet as non-auditable and spend mix_attr!=1 output => make sure other auditable Bob's wallets remain intact // - std::string bob_seed = bob_wlt->get_account().get_restore_braindata(); + std::string bob_seed = bob_wlt->get_account().get_seed_phrase(); bob_seed.erase(bob_seed.find_last_of(" ")); // remove the last word (with flags and checksum) to make seed old-format 25-words non-auditable with the same keys std::shared_ptr bob_wlt_non_auditable = std::make_shared(); @@ -1139,9 +1139,9 @@ bool hard_fork_2_alias_update_using_old_tx::generate(std::vector