mirror of
https://codeberg.org/nahuhh/wownero
synced 2026-12-03 06:34:03 +01:00
prevent mining within wallet and node
This commit is contained in:
@@ -331,107 +331,7 @@ bool t_command_parser_executor::print_transaction_pool_stats(const std::vector<s
|
||||
|
||||
bool t_command_parser_executor::start_mining(const std::vector<std::string>& args)
|
||||
{
|
||||
if(!args.size())
|
||||
{
|
||||
std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>|auto]" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
cryptonote::address_parse_info info;
|
||||
cryptonote::network_type nettype = cryptonote::MAINNET;
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, args.front()))
|
||||
{
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, args.front()))
|
||||
{
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, args.front()))
|
||||
{
|
||||
bool dnssec_valid;
|
||||
std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
|
||||
[](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, address_str))
|
||||
{
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, address_str))
|
||||
{
|
||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str))
|
||||
{
|
||||
std::cout << "target account address has wrong format" << std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nettype = cryptonote::STAGENET;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nettype = cryptonote::TESTNET;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nettype = cryptonote::STAGENET;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nettype = cryptonote::TESTNET;
|
||||
}
|
||||
}
|
||||
if (info.is_subaddress)
|
||||
{
|
||||
tools::fail_msg_writer() << "You can't use a subaddress to mine. You need to use your wallet's main address, which starts with \"Wo\"." << std::endl;
|
||||
return true;
|
||||
}
|
||||
if(nettype != cryptonote::MAINNET)
|
||||
std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << " address, make sure this is intentional!" << std::endl;
|
||||
uint64_t threads_count = 1;
|
||||
bool do_background_mining = false;
|
||||
bool ignore_battery = false;
|
||||
if(args.size() > 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.size() == 4)
|
||||
{
|
||||
if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
|
||||
{
|
||||
ignore_battery = true;
|
||||
}
|
||||
else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args.size() >= 3)
|
||||
{
|
||||
if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
|
||||
{
|
||||
do_background_mining = true;
|
||||
}
|
||||
else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args.size() >= 2)
|
||||
{
|
||||
if (args[1] == "auto" || args[1] == "autodetect")
|
||||
{
|
||||
threads_count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]);
|
||||
threads_count = (ok && 0 < threads_count) ? threads_count : 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery);
|
||||
|
||||
std::cout << "You can't mine within wownerod. To mine, restart node like this: ./wownerod --start-mining YOUR-ADDRESS --spendkey SECRET-SPENDKEY" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user