forked from lthn/blockchain
clean things up (massive names correction)
This commit is contained in:
parent
0cd37daaff
commit
dc08169aee
13 changed files with 44 additions and 44 deletions
|
|
@ -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<std::string> 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;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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<std::string> 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <txid>");
|
||||
|
||||
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 <filename> <password> - 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<std::string> &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<std::string> &args_)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::awo_blob(const std::vector<std::string> &args_)
|
||||
bool simple_wallet::tracking_seed(const std::vector<std::string> &args_)
|
||||
{
|
||||
if (!m_wallet->is_auditable())
|
||||
{
|
||||
|
|
@ -1510,8 +1510,8 @@ bool simple_wallet::awo_blob(const std::vector<std::string> &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;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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<std::string> &args = std::vector<std::string>());
|
||||
|
|
@ -81,7 +81,7 @@ namespace currency
|
|||
bool enable_console_logger(const std::vector<std::string> &args);
|
||||
bool integrated_address(const std::vector<std::string> &args);
|
||||
bool get_tx_key(const std::vector<std::string> &args_);
|
||||
bool awo_blob(const std::vector<std::string> &args_);
|
||||
bool tracking_seed(const std::vector<std::string> &args_);
|
||||
bool save_watch_only(const std::vector<std::string> &args);
|
||||
bool sign_transfer(const std::vector<std::string> &args);
|
||||
bool submit_transfer(const std::vector<std::string> &args);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<uint64_t, uint64_t> distribution;
|
||||
m_wallet.get_utxo_distribution(distribution);
|
||||
for (const auto& ent : distribution)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1036,13 +1036,13 @@ bool hard_fork_2_awo_wallets_basic_test<before_hf_2>::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<tools::wallet2> bob_wlt_awo_restored = std::make_shared<tools::wallet2>();
|
||||
|
||||
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<before_hf_2>::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<tools::wallet2> bob_wlt_non_auditable = std::make_shared<tools::wallet2>();
|
||||
|
|
@ -1139,9 +1139,9 @@ bool hard_fork_2_alias_update_using_old_tx<before_hf_2>::generate(std::vector<te
|
|||
test_core_time::adjust(ts);
|
||||
|
||||
m_accounts.resize(TOTAL_ACCS_COUNT);
|
||||
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); // miner_acc.restore_from_braindata("use use use use use use use use use use use use use use use use use use use use use use use use out");
|
||||
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); // miner_acc.restore_from_seed_phrase("use use use use use use use use use use use use use use use use use use use use use use use use out");
|
||||
miner_acc.set_createtime(ts);
|
||||
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); // alice_acc.restore_from_braindata("any any any any any any any any any any any any any any any any any any any any any any any any out");
|
||||
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); // alice_acc.restore_from_seed_phrase("any any any any any any any any any any any any any any any any any any any any any any any any out");
|
||||
alice_acc.set_createtime(ts);
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, ts);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue