1
0
Fork 0
forked from lthn/blockchain

Merge branch 'develop' into der_hint_improve

This commit is contained in:
cryptozoidberg 2019-09-27 17:24:41 +02:00
commit a38032d39a
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
15 changed files with 124 additions and 109 deletions

View file

@ -223,13 +223,23 @@ namespace file_io_utils
return str_result;
}
#endif
inline const std::wstring& convert_utf8_to_wstring_if_needed(const std::wstring& s)
{
return s;
}
inline std::wstring convert_utf8_to_wstring_if_needed(const std::string& s)
{
return epee::string_encoding::utf8_to_wstring(s);
}
template<class t_string>
bool is_file_exist(const t_string& path)
{
boost::filesystem::path p(path);
return boost::filesystem::exists(p);
}
{
boost::filesystem::path p(convert_utf8_to_wstring_if_needed(path));
return boost::filesystem::exists(p);
}
/*
inline
@ -262,19 +272,18 @@ namespace file_io_utils
template<class t_string>
bool save_string_to_file_throw(const t_string& path_to_file, const std::string& str)
{
//std::ofstream fstream;
boost::filesystem::ofstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
fstream << str;
fstream.close();
return true;
//std::ofstream fstream;
boost::filesystem::ofstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(convert_utf8_to_wstring_if_needed(path_to_file), std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
fstream << str;
fstream.close();
return true;
}
template<class t_string>
bool save_string_to_file(const t_string& path_to_file, const std::string& str)
{
try
{
return save_string_to_file_throw(path_to_file, str);
@ -291,13 +300,13 @@ namespace file_io_utils
}
template<class t_string>
bool load_file_to_string(const t_string& path_to_file, std::string& target_str)
bool load_file_to_string(const t_string& path_to_file, std::string& target_str)
{
try
{
boost::filesystem::ifstream fstream;
//fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
fstream.open(convert_utf8_to_wstring_if_needed(path_to_file), std::ios_base::binary | std::ios_base::in | std::ios::ate);
if (!fstream.good())
return false;
std::ifstream::pos_type file_size = fstream.tellg();
@ -316,7 +325,6 @@ namespace file_io_utils
fstream.close();
return true;
}
catch (...)
{
return false;
@ -354,7 +362,7 @@ namespace file_io_utils
bool get_file_time(const std::string& path_to_file, OUT time_t& ft)
{
boost::system::error_code ec;
ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec);
ft = boost::filesystem::last_write_time(epee::string_encoding::utf8_to_wstring(path_to_file), ec);
if(!ec)
return true;
else
@ -365,7 +373,7 @@ namespace file_io_utils
bool set_file_time(const std::string& path_to_file, const time_t& ft)
{
boost::system::error_code ec;
boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ft, ec);
boost::filesystem::last_write_time(epee::string_encoding::utf8_to_wstring(path_to_file), ft, ec);
if(!ec)
return true;
else
@ -468,20 +476,21 @@ namespace file_io_utils
bool copy_file(const std::string& source, const std::string& destination)
{
boost::system::error_code ec;
boost::filesystem::copy_file(source, destination, ec);
boost::filesystem::copy_file(epee::string_encoding::utf8_to_wstring(source), epee::string_encoding::utf8_to_wstring(destination), ec);
if (ec)
return false;
else
return true;
}
inline
bool append_string_to_file(const std::string& path_to_file, const std::string& str)
{
try
{
std::ofstream fstream;
boost::filesystem::ofstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file.c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::app);
fstream.open(epee::string_encoding::utf8_to_wstring(path_to_file), std::ios_base::binary | std::ios_base::out | std::ios_base::app);
fstream << str;
fstream.close();
return true;
@ -553,7 +562,7 @@ namespace file_io_utils
{
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
for ( boost::filesystem::directory_iterator itr( path ); itr != end_itr; ++itr )
for ( boost::filesystem::directory_iterator itr( epee::string_encoding::utf8_to_wstring(path) ); itr != end_itr; ++itr )
{
if ( only_files && boost::filesystem::is_directory(itr->status()) )
{

View file

@ -42,6 +42,7 @@
#include <boost/filesystem.hpp>
#include "warnings.h"
#include "auto_val_init.h"
#include "string_coding.h"
#ifndef OUT
@ -536,38 +537,15 @@ POP_GCC_WARNINGS
return module_folder;
}
//----------------------------------------------------------------------------
#ifdef _WIN32
inline std::string get_current_module_path()
inline bool set_module_name_and_folder(const std::string& path_to_process_)
{
char pname [5000] = {0};
GetModuleFileNameA( NULL, pname, sizeof(pname));
pname[sizeof(pname)-1] = 0; //be happy ;)
return pname;
}
#endif
//----------------------------------------------------------------------------
inline bool set_module_name_and_folder(const std::string& path_to_process_)
{
std::string path_to_process = path_to_process_;
boost::system::error_code ec;
path_to_process = boost::filesystem::canonical(path_to_process, ec).string();
#ifdef _WIN32
path_to_process = get_current_module_path();
#endif
std::string::size_type a = path_to_process.rfind( '\\' );
if(a == std::string::npos )
{
a = path_to_process.rfind( '/' );
}
if ( a != std::string::npos )
{
get_current_module_name() = path_to_process.substr(a+1, path_to_process.size());
get_current_module_folder() = path_to_process.substr(0, a);
return true;
}else
return false;
boost::filesystem::path path(epee::string_encoding::utf8_to_wstring(path_to_process_));
}
get_current_module_folder() = epee::string_encoding::wstring_to_utf8(path.parent_path().wstring());
get_current_module_name() = epee::string_encoding::wstring_to_utf8(path.filename().wstring());
return true;
}
//----------------------------------------------------------------------------
inline bool trim_left(std::string& str)
{

View file

@ -21,8 +21,8 @@ namespace tools
bool serialize_obj_to_file(t_object& obj, const std::string& file_path)
{
TRY_ENTRY();
std::ofstream data_file;
data_file.open( file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
boost::filesystem::ofstream data_file;
data_file.open( epee::string_encoding::utf8_to_wstring(file_path) , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
if(data_file.fail())
return false;
@ -64,8 +64,8 @@ namespace tools
{
TRY_ENTRY();
std::ifstream data_file;
data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
boost::filesystem::ifstream data_file;
data_file.open( epee::string_encoding::utf8_to_wstring(file_path), std::ios_base::binary | std::ios_base::in);
if(data_file.fail())
return false;
boost::archive::binary_iarchive a(data_file);

View file

@ -122,7 +122,7 @@ namespace command_line
boost::program_options::basic_parsed_options<charT> parse_command_line(int argc, const charT* const argv[],
const boost::program_options::options_description& desc, bool allow_unregistered = false)
{
auto parser = boost::program_options::command_line_parser(argc, argv);
auto parser = boost::program_options::basic_command_line_parser<charT>(argc, argv);
parser.options(desc);
if (allow_unregistered)
{

View file

@ -225,10 +225,10 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
// remove old incompatible DB
const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD;
if (boost::filesystem::exists(old_db_folder_path))
if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path)))
{
LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0);
boost::filesystem::remove_all(old_db_folder_path);
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path));
}
const std::string db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME;
@ -242,7 +242,7 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
{
// if DB could not be opened -- try to remove the whole folder and re-open DB
LOG_PRINT_YELLOW("Failed to initialize database in folder: " << db_folder_path << ", first attempt", LOG_LEVEL_0);
boost::filesystem::remove_all(db_folder_path);
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(db_folder_path));
res = m_db.open(db_folder_path, cache_size_l1);
CHECK_AND_ASSERT_MES(res, false, "Failed to initialize database in folder: " << db_folder_path << ", second attempt");
}
@ -312,7 +312,7 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
m_db_addr_to_alias.deinit();
m_db_per_block_gindex_incs.deinit();
m_db.close();
size_t files_removed = boost::filesystem::remove_all(db_folder_path);
size_t files_removed = boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(db_folder_path));
LOG_PRINT_L1(files_removed << " files at " << db_folder_path << " removed");
// try to re-create DB and re-init containers
@ -1821,8 +1821,8 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_
main_cumul_diff.pow_diff = main_pow_diff_end - main_pow_diff_begin;
//TODO: measurement of precise cumulative difficult
wide_difficulty_type alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff);
wide_difficulty_type main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff);
boost::multiprecision::uint1024_t alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff);
boost::multiprecision::uint1024_t main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff);
LOG_PRINT_L1("[FORK_CHOICE]: " << ENDL
<< "difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
<< "difficulty_pos_at_split_point:" << difficulty_pos_at_split_point << ENDL
@ -2644,7 +2644,8 @@ void blockchain_storage::print_blockchain_with_tx(uint64_t start_index, uint64_t
{
boost::filesystem::ofstream ss;
ss.exceptions(/*std::ifstream::failbit |*/ std::ifstream::badbit);
ss.open(log_space::log_singletone::get_default_log_folder() + "/blockchain_with_tx.txt", std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
ss.open(epee::string_encoding::utf8_to_wstring(log_space::log_singletone::get_default_log_folder() + "/blockchain_with_tx.txt"),
std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
CRITICAL_REGION_LOCAL(m_read_lock);

View file

@ -2713,7 +2713,7 @@ namespace currency
}
wide_difficulty_type get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
boost::multiprecision::uint1024_t get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
const wide_difficulty_type& difficulty_pow_at_split_point,
const difficulties& a_diff,
const difficulties& b_diff )
@ -2728,20 +2728,20 @@ namespace currency
boost::multiprecision::uint1024_t res =
(basic_sum * a_pow_cumulative_difficulty * a_pos_cumulative_difficulty) / (boost::multiprecision::uint1024_t(b_pow_cumulative_difficulty)*b_pos_cumulative_difficulty);
if (res > boost::math::tools::max_value<wide_difficulty_type>())
{
ASSERT_MES_AND_THROW("[INTERNAL ERROR]: Failed to get_a_to_b_relative_cumulative_difficulty, res = " << res << ENDL
<< ", difficulty_pos_at_split_point: " << difficulty_pos_at_split_point << ENDL
<< ", difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
<< ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
<< ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
<< ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
<< ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
);
}
// if (res > boost::math::tools::max_value<wide_difficulty_type>())
// {
// ASSERT_MES_AND_THROW("[INTERNAL ERROR]: Failed to get_a_to_b_relative_cumulative_difficulty, res = " << res << ENDL
// << ", difficulty_pos_at_split_point: " << difficulty_pos_at_split_point << ENDL
// << ", difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
// << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
// << ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
// );
// }
TRY_ENTRY();
wide_difficulty_type short_res = res.convert_to<wide_difficulty_type>();
return short_res;
// wide_difficulty_type short_res = res.convert_to<wide_difficulty_type>();
return res;
CATCH_ENTRY_WITH_FORWARDING_EXCEPTION();
}

View file

@ -604,7 +604,7 @@ namespace currency
wide_difficulty_type pow_diff;
};
wide_difficulty_type get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
boost::multiprecision::uint1024_t get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
const wide_difficulty_type& difficulty_pow_at_split_point,
const difficulties& a_diff,
const difficulties& b_diff

View file

@ -1125,10 +1125,10 @@ namespace currency
// remove old incompartible DB
const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_POOLDATA_FOLDERNAME_OLD;
if (boost::filesystem::exists(old_db_folder_path))
if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path)))
{
LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0);
boost::filesystem::remove_all(old_db_folder_path);
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path));
}
const std::string db_folder_path = m_config_folder + "/" CURRENCY_POOLDATA_FOLDERNAME;
@ -1142,7 +1142,7 @@ namespace currency
{
// if DB could not be opened -- try to remove the whole folder and re-open DB
LOG_PRINT_YELLOW("Failed to initialize database in folder: " << db_folder_path << ", first attempt", LOG_LEVEL_0);
boost::filesystem::remove_all(db_folder_path);
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(db_folder_path));
res = m_db.open(db_folder_path, cache_size_l1);
CHECK_AND_ASSERT_MES(res, false, "Failed to initialize database in folder: " << db_folder_path << ", second attempt");
}
@ -1182,7 +1182,7 @@ namespace currency
m_db_alias_addresses.deinit();
m_db_solo_options.deinit();
m_db.close();
size_t files_removed = boost::filesystem::remove_all(db_folder_path);
size_t files_removed = boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(db_folder_path));
LOG_PRINT_L1(files_removed << " files at " << db_folder_path << " removed");
// try to re-create DB and re-init containers

View file

@ -172,8 +172,8 @@ int main(int argc, char* argv[])
std::string data_dir = command_line::get_arg(vm, command_line::arg_data_dir);
std::string config = command_line::get_arg(vm, command_line::arg_config_file);
boost::filesystem::path data_dir_path(data_dir);
boost::filesystem::path config_path(config);
boost::filesystem::path data_dir_path(epee::string_encoding::utf8_to_wstring(data_dir));
boost::filesystem::path config_path(epee::string_encoding::utf8_to_wstring(config));
if (!config_path.has_parent_path())
{
config_path = data_dir_path / config_path;

View file

@ -154,8 +154,8 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
m_data_dir = command_line::get_arg(m_vm, command_line::arg_data_dir);
std::string config = command_line::get_arg(m_vm, command_line::arg_config_file);
boost::filesystem::path data_dir_path(m_data_dir);
boost::filesystem::path config_path(config);
boost::filesystem::path data_dir_path(epee::string_encoding::utf8_to_wstring(m_data_dir));
boost::filesystem::path config_path(epee::string_encoding::utf8_to_wstring(config));
if (!config_path.has_parent_path())
{
config_path = data_dir_path / config_path;
@ -393,6 +393,7 @@ bool daemon_backend::deinit_local_daemon()
LOG_PRINT_L0("Deinitializing p2p...");
//dsi.text_state = "Deinitializing p2p";
m_pview->update_daemon_status(dsi);
m_p2psrv.deinit();
m_ccore.set_currency_protocol(NULL);
m_cprotocol.set_p2p_endpoint(NULL);

View file

@ -75,14 +75,14 @@ namespace gui_tools
{
namespace fs = boost::filesystem;
char pszPath[MAX_PATH] = "";
wchar_t pszPath[MAX_PATH] = L"";
if (SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate))
if (SHGetSpecialFolderPathW(NULL, pszPath, nFolder, fCreate))
{
return fs::path(pszPath);
}
//LogPrintf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n");
//LogPrintf("SHGetSpecialFolderPathW() failed, could not obtain requested path.\n");
return fs::path("");
}
#endif

View file

@ -316,12 +316,12 @@ bool MainWindow::load_app_config()
CATCH_ENTRY2(false);
}
bool MainWindow::init(const std::string& htmlPath)
bool MainWindow::init(const std::string& html_path)
{
TRY_ENTRY();
//QtWebEngine::initialize();
init_tray_icon(htmlPath);
set_html_path(htmlPath);
init_tray_icon(html_path);
set_html_path(html_path);
m_backend.subscribe_to_core_events(this);
@ -354,7 +354,7 @@ void MainWindow::on_menu_show()
CATCH_ENTRY2(void());
}
void MainWindow::init_tray_icon(const std::string& htmlPath)
void MainWindow::init_tray_icon(const std::string& html_path)
{
TRY_ENTRY();
if (!QSystemTrayIcon::isSystemTrayAvailable())
@ -384,14 +384,14 @@ void MainWindow::init_tray_icon(const std::string& htmlPath)
//setup icon
#ifdef TARGET_OS_MAC
m_normal_icon_path = htmlPath + "/files/app22macos.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = htmlPath + "/files/app22macos_blocked.png"; // X11 tray icon size is 22x22
m_normal_icon_path = html_path + "/files/app22macos.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = html_path + "/files/app22macos_blocked.png"; // X11 tray icon size is 22x22
#else
m_normal_icon_path = htmlPath + "/files/app22windows.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = htmlPath + "/files/app22windows_blocked.png"; // X11 tray icon size
m_normal_icon_path = html_path + "/files/app22windows.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = html_path + "/files/app22windows_blocked.png"; // X11 tray icon size
#endif
//setWindowIcon(QIcon(iconPath.c_str()));
QIcon qi(m_normal_icon_path.c_str());
QIcon qi( QString::fromWCharArray(epee::string_encoding::utf8_to_wstring(m_normal_icon_path).c_str()) );
qi.setIsMask(true);
m_tray_icon->setIcon(qi);
m_tray_icon->setToolTip(CURRENCY_NAME_BASE);
@ -411,7 +411,7 @@ void MainWindow::bool_toggle_icon(const QString& param)
else
path = m_normal_icon_path;
QIcon qi(path.c_str());
QIcon qi( QString::fromWCharArray(epee::string_encoding::utf8_to_wstring(path).c_str()) );
qi.setIsMask(true);
m_tray_icon->setIcon(qi);
CATCH_ENTRY2(void());
@ -771,7 +771,7 @@ bool MainWindow::set_html_path(const std::string& path)
TRY_ENTRY();
//init_tray_icon(path);
#ifdef _MSC_VER
QString url = QString::fromUtf8(epee::string_encoding::convert_ansii_to_utf8(path).c_str()) + "/index.html";
QString url = QString::fromUtf8(path.c_str()) + "/index.html";
load_file(url);
#else
// load_file(QString((std::string("file://") + path + "/index.html").c_str()));
@ -1232,7 +1232,7 @@ QString MainWindow::have_secure_app_data()
view::api_response ar = AUTO_VAL_INIT(ar);
boost::system::error_code ec;
if (boost::filesystem::exists(m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME, ec))
if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME), ec))
ar.error_code = API_RETURN_CODE_TRUE;
else
ar.error_code = API_RETURN_CODE_FALSE;
@ -1240,6 +1240,7 @@ QString MainWindow::have_secure_app_data()
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::drop_secure_app_data()
{
TRY_ENTRY();
@ -1247,13 +1248,14 @@ QString MainWindow::drop_secure_app_data()
view::api_response ar = AUTO_VAL_INIT(ar);
boost::system::error_code ec;
if (boost::filesystem::remove(m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME, ec))
if (boost::filesystem::remove(epee::string_encoding::utf8_to_wstring(m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME), ec))
ar.error_code = API_RETURN_CODE_TRUE;
else
ar.error_code = API_RETURN_CODE_FALSE;
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::get_all_aliases()
{
TRY_ENTRY();

View file

@ -42,8 +42,16 @@ int main(int argc, char *argv[])
#endif
#ifdef WIN32
WCHAR sz_file_name[MAX_PATH + 1] = L"";
::GetModuleFileNameW(NULL, sz_file_name, MAX_PATH + 1);
std::string path_to_process_utf8 = epee::string_encoding::wstring_to_utf8(sz_file_name);
#else
std::string path_to_process_utf8 = argv[0];
#endif
TRY_ENTRY();
epee::string_tools::set_module_name_and_folder(argv[0]);
epee::string_tools::set_module_name_and_folder(path_to_process_utf8);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#ifdef _MSC_VER
#if _MSC_VER >= 1910

View file

@ -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)
{

View file

@ -7,6 +7,6 @@
#define PROJECT_REVISION "0"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 58
#define PROJECT_VERSION_BUILD_NO 60
#define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"