forked from lthn/blockchain
filesystem unicode support: simplewallet improvements (command line made unicode-able) #121
This commit is contained in:
parent
ef8f61fbc4
commit
91dc7e6457
1 changed files with 21 additions and 5 deletions
|
|
@ -331,7 +331,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
}
|
||||
else
|
||||
{
|
||||
bool r = open_wallet(epee::string_encoding::convert_to_ansii(m_wallet_file), pwd_container.password());
|
||||
bool r = open_wallet(m_wallet_file, pwd_container.password());
|
||||
CHECK_AND_ASSERT_MES(r, false, "could not open account");
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +379,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas
|
|||
m_wallet->set_do_rise_transfer(false);
|
||||
try
|
||||
{
|
||||
m_wallet->generate(epee::string_encoding::convert_to_unicode(m_wallet_file), password);
|
||||
m_wallet->generate(epee::string_encoding::utf8_to_wstring(m_wallet_file), password);
|
||||
message_writer(epee::log_space::console_color_white, true) << "Generated new wallet: " << m_wallet->get_account().get_public_address_str();
|
||||
std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl << std::flush;
|
||||
if(m_do_not_set_date)
|
||||
|
|
@ -421,7 +421,7 @@ bool simple_wallet::restore_wallet(const std::string &wallet_file, const std::st
|
|||
m_wallet->set_do_rise_transfer(false);
|
||||
try
|
||||
{
|
||||
m_wallet->restore(epee::string_encoding::convert_to_unicode(wallet_file), password, restore_seed);
|
||||
m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, restore_seed);
|
||||
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().m_view_secret_key) << std::endl << std::flush;
|
||||
if (m_do_not_set_date)
|
||||
|
|
@ -457,7 +457,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa
|
|||
{
|
||||
try
|
||||
{
|
||||
m_wallet->load(epee::string_encoding::convert_to_unicode(m_wallet_file), password);
|
||||
m_wallet->load(epee::string_encoding::utf8_to_wstring(m_wallet_file), password);
|
||||
message_writer(epee::log_space::console_color_white, true) << "Opened" << (m_wallet->is_watch_only() ? " watch-only" : "") << " wallet: " << m_wallet->get_account().get_public_address_str();
|
||||
|
||||
if (m_print_brain_wallet)
|
||||
|
|
@ -1512,7 +1512,11 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
#ifdef WIN32
|
||||
int wmain( int argc, wchar_t* argv_w[ ], wchar_t* envp[ ] )
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
|
@ -1528,6 +1532,18 @@ int main(int argc, char* argv[])
|
|||
std::fflush(nullptr);
|
||||
});
|
||||
|
||||
#ifdef WIN32
|
||||
// windows: convert argv_w into UTF-8-encoded std::string the same way it is in Linux and macOS
|
||||
std::vector<std::string> argv_str;
|
||||
std::vector<const char*> argv_vec;
|
||||
for (size_t i = 0; i < argc; ++i)
|
||||
{
|
||||
argv_str.push_back( epee::string_encoding::wstring_to_utf8( argv_w[i] ) );
|
||||
argv_vec.push_back( argv_str.back().c_str() );
|
||||
}
|
||||
const char* const* argv = argv_vec.data();
|
||||
#endif
|
||||
|
||||
string_tools::set_module_name_and_folder(argv[0]);
|
||||
|
||||
po::options_description desc_general("General options");
|
||||
|
|
@ -1662,7 +1678,7 @@ int main(int argc, char* argv[])
|
|||
try
|
||||
{
|
||||
LOG_PRINT_L0("Loading wallet...");
|
||||
wal.load(epee::string_encoding::convert_to_unicode(wallet_file), pwd_container.password());
|
||||
wal.load(epee::string_encoding::utf8_to_wstring(wallet_file), pwd_container.password());
|
||||
}
|
||||
catch (const tools::error::wallet_load_notice_wallet_restored& e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue