forked from lthn/blockchain
Merge branch 'develop' of github.com:hyle-team/zano into develop
This commit is contained in:
commit
601dd3560c
9 changed files with 113 additions and 24 deletions
|
|
@ -1550,8 +1550,8 @@ namespace currency
|
|||
bool check_tx_derivation_hint(const transaction& tx, const crypto::key_derivation& derivation)
|
||||
{
|
||||
bool found_der_xor = false;
|
||||
uint16_t my_derive_xor = get_derivation_hint(derivation);
|
||||
tx_derivation_hint dh = make_tx_derivation_hint_from_uint16(my_derive_xor);
|
||||
uint16_t hint = get_derivation_hint(derivation);
|
||||
tx_derivation_hint dh = make_tx_derivation_hint_from_uint16(hint);
|
||||
for (auto& e : tx.extra)
|
||||
{
|
||||
if (e.type() == typeid(tx_derivation_hint))
|
||||
|
|
@ -1737,7 +1737,13 @@ namespace currency
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
bool validate_password(const std::string& password)
|
||||
{
|
||||
static const std::string allowed_password_symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!?@#$%^&*_+|{}[]()<>:;\"'-=\\/.,";
|
||||
size_t n = password.find_first_not_of(allowed_password_symbols, 0);
|
||||
return n == std::string::npos;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
#define ANTI_OVERFLOW_AMOUNT 1000000
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ namespace currency
|
|||
uint64_t get_string_uint64_hash(const std::string& str);
|
||||
bool construct_tx_out(const tx_destination_entry& de, const crypto::secret_key& tx_sec_key, size_t output_index, transaction& tx, std::set<uint16_t>& deriv_cache, uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED);
|
||||
bool validate_alias_name(const std::string& al);
|
||||
bool validate_password(const std::string& password);
|
||||
void get_attachment_extra_info_details(const std::vector<attachment_v>& attachment, extra_attachment_info& eai);
|
||||
bool construct_tx(const account_keys& sender_account_keys,
|
||||
const std::vector<tx_source_entry>& sources,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ daemon_backend::daemon_backend():m_pview(&m_view_stub),
|
|||
m_offers_service(nullptr),
|
||||
m_ui_opt(AUTO_VAL_INIT(m_ui_opt)),
|
||||
m_remote_node_mode(false),
|
||||
m_is_pos_allowed(false)
|
||||
m_is_pos_allowed(false),
|
||||
m_qt_logs_enbaled(false)
|
||||
{
|
||||
m_offers_service.set_disabled(true);
|
||||
//m_ccore.get_blockchain_storage().get_attachment_services_manager().add_service(&m_offers_service);
|
||||
|
|
@ -52,6 +53,7 @@ const command_line::arg_descriptor<std::string> arg_xcode_stub = {"-NSDocumentRe
|
|||
const command_line::arg_descriptor<bool> arg_enable_gui_debug_mode = { "gui-debug-mode", "Enable debug options in GUI", false, true };
|
||||
const command_line::arg_descriptor<uint32_t> arg_qt_remote_debugging_port = { "remote-debugging-port", "Specify port for Qt remote debugging", 30333, true };
|
||||
const command_line::arg_descriptor<std::string> arg_remote_node = { "remote-node", "Switch GUI to work with remote node instead of local daemon", "", true };
|
||||
const command_line::arg_descriptor<bool> arg_enable_qt_logs = { "enable-qt-logs", "Forward Qt log messages into main log", false, true };
|
||||
|
||||
void wallet_lock_time_watching_policy::watch_lock_time(uint64_t lock_time)
|
||||
{
|
||||
|
|
@ -124,9 +126,7 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
|
|||
command_line::add_arg(desc_cmd_sett, arg_enable_gui_debug_mode);
|
||||
command_line::add_arg(desc_cmd_sett, arg_qt_remote_debugging_port);
|
||||
command_line::add_arg(desc_cmd_sett, arg_remote_node);
|
||||
|
||||
|
||||
|
||||
command_line::add_arg(desc_cmd_sett, arg_enable_qt_logs);
|
||||
|
||||
|
||||
currency::core::init_options(desc_cmd_sett);
|
||||
|
|
@ -220,6 +220,8 @@ bool daemon_backend::init(int argc, char* argv[], view::i_view* pview_handler)
|
|||
// configure for remote node
|
||||
}
|
||||
|
||||
m_qt_logs_enbaled = command_line::get_arg(m_vm, arg_enable_qt_logs);
|
||||
|
||||
m_pview->init(path_to_html);
|
||||
|
||||
if (!coomand_line_parsed)
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ public:
|
|||
void unsubscribe_to_core_events();
|
||||
void get_gui_options(view::gui_options& opt);
|
||||
std::string get_wallet_log_prefix(size_t wallet_id) const;
|
||||
bool is_qt_logs_enabled() const { return m_qt_logs_enbaled; }
|
||||
|
||||
private:
|
||||
void main_worker(const po::variables_map& vm);
|
||||
|
|
@ -187,6 +188,7 @@ private:
|
|||
currency::core_rpc_server m_rpc_server;
|
||||
|
||||
bool m_remote_node_mode;
|
||||
bool m_qt_logs_enbaled;
|
||||
std::atomic<bool> m_is_pos_allowed;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -609,10 +609,45 @@ bool MainWindow::show_msg_box(const std::string& message)
|
|||
return true;
|
||||
CATCH_ENTRY2(false);
|
||||
}
|
||||
|
||||
void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
QByteArray local_msg = msg.toLocal8Bit();
|
||||
const char* msg_type = "";
|
||||
switch (type)
|
||||
{
|
||||
case QtDebugMsg: msg_type = "DEBG "; break;
|
||||
case QtInfoMsg: msg_type = "INFO "; break;
|
||||
case QtWarningMsg: msg_type = "WARN "; break;
|
||||
case QtCriticalMsg: msg_type = "CRIT "; break;
|
||||
case QtFatalMsg: msg_type = "FATAL "; break;
|
||||
}
|
||||
|
||||
if (context.file == nullptr && context.function == nullptr)
|
||||
{
|
||||
// no debug info
|
||||
LOG_PRINT("[QT] " << msg_type << local_msg.constData(), LOG_LEVEL_0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// some debug info
|
||||
LOG_PRINT("[QT] " << msg_type << local_msg.constData() << " @ " << (context.file ? context.file : "") << ":" << context.line << ", " << (context.function ? context.function : ""), LOG_LEVEL_0);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::init_backend(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
return m_backend.init(argc, argv, this);
|
||||
if (!m_backend.init(argc, argv, this))
|
||||
return false;
|
||||
|
||||
if (m_backend.is_qt_logs_enabled())
|
||||
{
|
||||
qInstallMessageHandler(qt_log_message_handler);
|
||||
QLoggingCategory::setFilterRules("*=true"); // enable all logs
|
||||
}
|
||||
|
||||
return true;
|
||||
CATCH_ENTRY2(false);
|
||||
}
|
||||
|
||||
|
|
@ -999,6 +1034,7 @@ void MainWindow::on_complete_events()
|
|||
}
|
||||
CATCH_ENTRY2(void());
|
||||
}
|
||||
|
||||
void MainWindow::on_clear_events()
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
|
@ -1020,9 +1056,13 @@ QString MainWindow::get_secure_app_data(const QString& param)
|
|||
}
|
||||
|
||||
std::string app_data_buff;
|
||||
bool r = file_io_utils::load_file_to_string(m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME, app_data_buff);
|
||||
std::string filename = m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME;
|
||||
bool r = file_io_utils::load_file_to_string(filename, app_data_buff);
|
||||
if (!r)
|
||||
{
|
||||
LOG_PRINT_L1("config file was not loaded: " << m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME);
|
||||
return "";
|
||||
}
|
||||
|
||||
if (app_data_buff.size() < sizeof(app_data_file_binary_header))
|
||||
{
|
||||
|
|
@ -1045,23 +1085,38 @@ QString MainWindow::get_secure_app_data(const QString& param)
|
|||
|
||||
m_master_password = pwd.pass;
|
||||
|
||||
crypto::hash master_password_pre_hash = crypto::cn_fast_hash(m_master_password.c_str(), m_master_password.length());
|
||||
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
|
||||
LOG_PRINT_L0("get_secure_app_data, pass hash: " << master_password_hash);
|
||||
|
||||
return app_data_buff.substr(sizeof(app_data_file_binary_header)).c_str();
|
||||
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
QString MainWindow::set_master_password(const QString& param)
|
||||
{
|
||||
view::api_response ar;
|
||||
|
||||
view::password_data pwd = AUTO_VAL_INIT(pwd);
|
||||
|
||||
if (!epee::serialization::load_t_from_json(pwd, param.toStdString()))
|
||||
{
|
||||
view::api_response ar;
|
||||
ar.error_code = API_RETURN_CODE_BAD_ARG;
|
||||
return MAKE_RESPONSE(ar);
|
||||
}
|
||||
|
||||
if (!currency::validate_password(pwd.pass))
|
||||
{
|
||||
ar.error_code = API_RETURN_CODE_BAD_ARG;
|
||||
return MAKE_RESPONSE(ar);
|
||||
}
|
||||
|
||||
m_master_password = pwd.pass;
|
||||
|
||||
view::api_response ar;
|
||||
crypto::hash master_password_pre_hash = crypto::cn_fast_hash(m_master_password.c_str(), m_master_password.length());
|
||||
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
|
||||
LOG_PRINT_L0("set_master_password, pass hash: " << master_password_hash);
|
||||
|
||||
ar.error_code = API_RETURN_CODE_OK;
|
||||
return MAKE_RESPONSE(ar);
|
||||
}
|
||||
|
|
@ -1076,11 +1131,18 @@ QString MainWindow::check_master_password(const QString& param)
|
|||
ar.error_code = API_RETURN_CODE_BAD_ARG;
|
||||
return MAKE_RESPONSE(ar);
|
||||
}
|
||||
|
||||
crypto::hash master_password_pre_hash = crypto::cn_fast_hash(m_master_password.c_str(), m_master_password.length());
|
||||
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
|
||||
crypto::hash pwd_pre_hash = crypto::cn_fast_hash(pwd.pass.c_str(), pwd.pass.length());
|
||||
crypto::hash pwd_hash = crypto::cn_fast_hash(&pwd_pre_hash, sizeof pwd_pre_hash);
|
||||
|
||||
if (m_master_password != pwd.pass)
|
||||
{
|
||||
ar.error_code = API_RETURN_CODE_WRONG_PASSWORD;
|
||||
}else
|
||||
LOG_PRINT_L0("check_master_password: pwd hash: " << pwd_hash << ", expected: " << master_password_hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
ar.error_code = API_RETURN_CODE_OK;
|
||||
}
|
||||
|
|
@ -1099,18 +1161,27 @@ QString MainWindow::store_app_data(const QString& param)
|
|||
return MAKE_RESPONSE(ar);
|
||||
}
|
||||
|
||||
//bool r = file_io_utils::save_string_to_file(m_backend.get_config_folder() + "/" + GUI_CONFIG_FILENAME, param.toStdString());
|
||||
bool r = file_io_utils::save_string_to_file(m_backend.get_config_folder() + "/" + GUI_CONFIG_FILENAME, param.toStdString());
|
||||
//view::api_response ar;
|
||||
if (r)
|
||||
ar.error_code = API_RETURN_CODE_OK;
|
||||
else
|
||||
ar.error_code = API_RETURN_CODE_FAIL;
|
||||
crypto::hash master_password_pre_hash = crypto::cn_fast_hash(m_master_password.c_str(), m_master_password.length());
|
||||
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
|
||||
LOG_PRINT_L0("store_app_data, pass hash: " << master_password_hash);
|
||||
|
||||
std::string filename = m_backend.get_config_folder() + "/" + GUI_CONFIG_FILENAME;
|
||||
bool r = file_io_utils::save_string_to_file(filename, param.toStdString());
|
||||
if (r)
|
||||
{
|
||||
ar.error_code = API_RETURN_CODE_OK;
|
||||
LOG_PRINT_L1("config saved: " << filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
ar.error_code = API_RETURN_CODE_FAIL;
|
||||
LOG_PRINT_L1("config save failed: " << filename);
|
||||
}
|
||||
|
||||
//ar.error_code = store_to_file((m_backend.get_config_folder() + "/" + GUI_CONFIG_FILENAME).c_str(), param).toStdString();
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
|
||||
QString MainWindow::is_file_exist(const QString& path)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
|
@ -1123,7 +1194,7 @@ QString MainWindow::is_file_exist(const QString& path)
|
|||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
LOG_ERROR("FILED TO STORE TO FILE: " << path.toStdString() << " ERROR:" << ex.what());
|
||||
LOG_ERROR("failed to check file existance: " << path.toStdString() << " ERROR:" << ex.what());
|
||||
return QString(API_RETURN_CODE_ALREADY_EXISTS) + ": " + ex.what();
|
||||
}
|
||||
|
||||
|
|
@ -1133,6 +1204,7 @@ QString MainWindow::is_file_exist(const QString& path)
|
|||
}
|
||||
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
QString MainWindow::store_to_file(const QString& path, const QString& buff)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
|
@ -1221,6 +1293,10 @@ QString MainWindow::store_secure_app_data(const QString& param)
|
|||
else
|
||||
ar.error_code = API_RETURN_CODE_FAIL;
|
||||
|
||||
crypto::hash master_password_pre_hash = crypto::cn_fast_hash(m_master_password.c_str(), m_master_password.length());
|
||||
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
|
||||
LOG_PRINT_L0("store_secure_app_data, r = " << r << ", pass hash: " << master_password_hash);
|
||||
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@
|
|||
#define PROJECT_REVISION "0"
|
||||
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
|
||||
|
||||
#define PROJECT_VERSION_BUILD_NO 62
|
||||
#define PROJECT_VERSION_BUILD_NO 64
|
||||
#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 "]"
|
||||
|
|
|
|||
|
|
@ -1962,6 +1962,7 @@ void wallet2::assign_account(const currency::account_base& acc)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::generate(const std::wstring& path, const std::string& pass)
|
||||
{
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(validate_password(pass), "new wallet generation failed: password contains forbidden characters")
|
||||
clear();
|
||||
prepare_file_names(path);
|
||||
m_password = pass;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ ENABLE_CHANNEL_BY_DEFAULT("wallet");
|
|||
#define WLT_CHECK_AND_ASSERT_MES(expr, ret, msg) CHECK_AND_ASSERT_MES(expr, ret, "[W:" << m_log_prefix << "]" << msg)
|
||||
#define WLT_CHECK_AND_ASSERT_MES_NO_RET(expr, msg) CHECK_AND_ASSERT_MES_NO_RET(expr, "[W:" << m_log_prefix << "]" << msg)
|
||||
#define WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, "[W:" << m_log_prefix << "]" << msg)
|
||||
#define WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, "[W:" << m_log_prefix << "]" << msg)
|
||||
|
||||
class test_generator;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ bool if_alt_chain_stronger(const currency::wide_difficulty_type& pos, const curr
|
|||
alt_cumul_diff.pos_diff = pos;
|
||||
static currency::wide_difficulty_type difficulty_pos_at_split_point = 400000;
|
||||
static currency::wide_difficulty_type difficulty_pow_at_split_point = 4000;
|
||||
currency::wide_difficulty_type main = currency::get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff);
|
||||
currency::wide_difficulty_type alt = currency::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 = currency::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 = currency::get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff);
|
||||
if (alt > main)
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue