Merge pull request 'pass' (#391) from wowario/wownero:pass into dev-v0.10

Reviewed-on: #391
pull/393/head 10.0.0
wowario 3 years ago
commit 7ee6da17fa

@ -102,6 +102,7 @@ namespace cryptonote
const command_line::arg_descriptor<uint64_t> arg_bg_mining_min_idle_interval_seconds = {"bg-mining-min-idle-interval", "Specify min lookback interval in seconds for determining idle state", miner::BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS, true};
const command_line::arg_descriptor<uint16_t> arg_bg_mining_idle_threshold_percentage = {"bg-mining-idle-threshold", "Specify minimum avg idle percentage over lookback interval", miner::BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE, true};
const command_line::arg_descriptor<uint16_t> arg_bg_mining_miner_target_percentage = {"bg-mining-miner-target", "Specify maximum percentage cpu use by miner(s)", miner::BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE, true};
const command_line::arg_descriptor<std::string> arg_spendkey = {"spendkey", "Specify secret spend key used for mining", "", true};
}
@ -294,10 +295,22 @@ namespace cryptonote
command_line::add_arg(desc, arg_bg_mining_min_idle_interval_seconds);
command_line::add_arg(desc, arg_bg_mining_idle_threshold_percentage);
command_line::add_arg(desc, arg_bg_mining_miner_target_percentage);
command_line::add_arg(desc, arg_spendkey);
}
//-----------------------------------------------------------------------------------------------------
bool miner::init(const boost::program_options::variables_map& vm, network_type nettype)
{
if(command_line::has_arg(vm, arg_spendkey))
{
std::string skey_str = command_line::get_arg(vm, arg_spendkey);
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(skey_str, spendkey);
crypto::secret_key viewkey;
keccak((uint8_t *)&spendkey, 32, (uint8_t *)&viewkey, 32);
sc_reduce32((uint8_t *)&viewkey);
m_spendkey = spendkey;
m_viewkey = viewkey;
}
if(command_line::has_arg(vm, arg_extra_messages))
{
std::string buff;
@ -371,22 +384,6 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------------
bool miner::start(const account_public_address& adr, size_t threads_count, bool do_background, bool ignore_battery)
{
if (!boost::filesystem::exists("spend.key"))
{
MGINFO_RED("Warning: \"spend.key\" file does not exist. As of version 10, you need to export \nyour secret spend key from wownero-wallet-cli with \"export_key\" command so you \ncan sign blocks with your private key.");
}
std::ifstream key_file("spend.key");
std::string skey_str;
std::getline(key_file, skey_str);
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(skey_str, spendkey);
crypto::secret_key viewkey;
keccak((uint8_t *)&spendkey, 32, (uint8_t *)&viewkey, 32);
sc_reduce32((uint8_t *)&viewkey);
m_spendkey = spendkey;
m_viewkey = viewkey;
m_block_reward = 0;
m_mine_address = adr;
m_threads_total = static_cast<uint32_t>(threads_count);

@ -1319,7 +1319,7 @@ namespace cryptonote
}
if(!miner.start(info.address, static_cast<size_t>(req.threads_count), req.do_background_mining, req.ignore_battery))
{
res.status = "Failed, mining not started. You might need to export spend key first.";
res.status = "Failed, mining not started.";
LOG_PRINT_L0(res.status);
return true;
}

@ -489,7 +489,7 @@ namespace rpc
if(!m_core.get_miner().start(info.address, static_cast<size_t>(req.threads_count), req.do_background_mining, req.ignore_battery))
{
res.error_details = "Failed, mining not started. You might need to export spend key first.";
res.error_details = "Failed, mining not started.";
LOG_PRINT_L0(res.error_details);
res.status = Message::STATUS_FAILED;
return;

@ -3300,9 +3300,6 @@ simple_wallet::simple_wallet()
boost::bind(&simple_wallet::on_command, this, &simple_wallet::start_mining, _1),
tr(USAGE_START_MINING),
tr("Start mining in the daemon (bg_mining and ignore_battery are optional booleans)."));
m_cmd_binder.set_handler("export_key",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::export_key, _1),
tr("Export secret spend key used for mining."));
m_cmd_binder.set_handler("stop_mining",
boost::bind(&simple_wallet::on_command, this, &simple_wallet::stop_mining, _1),
tr("Stop mining in the daemon."));
@ -5522,25 +5519,6 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::export_key(const std::vector<std::string>& args)
{
const auto pwd_container = get_and_verify_password();
if (pwd_container)
{
crypto::secret_key skey;
skey = m_wallet->get_account().get_keys().m_spend_secret_key;
std::string skey_str;
skey_str = epee::string_tools::pod_to_hex(skey);
std::ofstream key_file;
key_file.open("spend.key");
key_file << skey_str;
key_file.close();
success_msg_writer() << tr("Secret spend key exported.");
m_wallet->rewrite(m_wallet_file, pwd_container->password());
}
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::stop_mining(const std::vector<std::string>& args)
{
if (!try_connect_to_daemon())

@ -160,7 +160,6 @@ namespace cryptonote
bool apropos(const std::vector<std::string> &args);
bool scan_tx(const std::vector<std::string> &args);
bool start_mining(const std::vector<std::string> &args);
bool export_key(const std::vector<std::string> &args);
bool stop_mining(const std::vector<std::string> &args);
bool set_daemon(const std::vector<std::string> &args);
bool save_bc(const std::vector<std::string> &args);

Loading…
Cancel
Save