Separate testnet address prefix

This commit is contained in:
Zachary Michaels 2014-09-09 10:58:53 -04:00 committed by Riccardo Spagni
parent ee1bacc64f
commit d03308734b
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
21 changed files with 126 additions and 69 deletions

View File

@ -128,7 +128,7 @@ namespace config
namespace testnet
{
uint64_t const CRYPTONOTE_ADDRESS_BASE58_PREFIX = 19; // addresses start with "5"
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 19; // addresses start with "5"
uint16_t const P2P_DEFAULT_PORT = 28080;
uint16_t const RPC_DEFAULT_PORT = 28081;
boost::uuids::uuid const NETWORK_ID = { {

View File

@ -93,10 +93,10 @@ DISABLE_VS_WARNINGS(4244 4345)
return m_keys;
}
//-----------------------------------------------------------------
std::string account_base::get_public_address_str()
std::string account_base::get_public_address_str(bool testnet)
{
//TODO: change this code into base 58
return get_account_address_as_str(m_keys.m_account_address);
return get_account_address_as_str(testnet, m_keys.m_account_address);
}
//-----------------------------------------------------------------
}

View File

@ -59,7 +59,7 @@ namespace cryptonote
account_base();
crypto::secret_key generate(const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false, bool two_random = false);
const account_keys& get_keys() const;
std::string get_public_address_str();
std::string get_public_address_str(bool testnet);
uint64_t get_createtime() const { return m_creation_timestamp; }
void set_createtime(uint64_t val) { m_creation_timestamp = val; }

View File

@ -103,9 +103,15 @@ namespace cryptonote {
return summ;
}
//-----------------------------------------------------------------------
std::string get_account_address_as_str(const account_public_address& adr)
std::string get_account_address_as_str(
bool testnet
, account_public_address const & adr
)
{
return tools::base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(adr));
uint64_t address_prefix = testnet ?
config::testnet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX : config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
return tools::base58::encode_addr(address_prefix, t_serializable_object_to_blob(adr));
}
//-----------------------------------------------------------------------
bool is_coinbase(const transaction& tx)
@ -119,8 +125,15 @@ namespace cryptonote {
return true;
}
//-----------------------------------------------------------------------
bool get_account_address_from_str(account_public_address& adr, const std::string& str)
bool get_account_address_from_str(
account_public_address& adr
, bool testnet
, std::string const & str
)
{
uint64_t address_prefix = testnet ?
config::testnet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX : config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
if (2 * sizeof(public_address_outer_blob) != str.size())
{
blobdata data;
@ -131,9 +144,9 @@ namespace cryptonote {
return false;
}
if (config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX != prefix)
if (address_prefix != prefix)
{
LOG_PRINT_L1("Wrong address prefix: " << prefix << ", expected " << config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
LOG_PRINT_L1("Wrong address prefix: " << prefix << ", expected " << address_prefix);
return false;
}

View File

@ -66,8 +66,18 @@ namespace cryptonote {
size_t get_max_tx_size();
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward);
uint8_t get_account_address_checksum(const public_address_outer_blob& bl);
std::string get_account_address_as_str(const account_public_address& adr);
bool get_account_address_from_str(account_public_address& adr, const std::string& str);
std::string get_account_address_as_str(
bool testnet
, const account_public_address& adr
);
bool get_account_address_from_str(
account_public_address& adr
, bool testnet
, const std::string& str
);
bool is_coinbase(const transaction& tx);
bool operator ==(const cryptonote::transaction& a, const cryptonote::transaction& b);

View File

@ -127,7 +127,7 @@ namespace cryptonote
r = m_blockchain_storage.init(m_config_folder, testnet);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
r = m_miner.init(vm);
r = m_miner.init(vm, testnet);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
return load_state_data();

View File

@ -171,7 +171,7 @@ namespace cryptonote
command_line::add_arg(desc, arg_mining_threads);
}
//-----------------------------------------------------------------------------------------------------
bool miner::init(const boost::program_options::variables_map& vm)
bool miner::init(const boost::program_options::variables_map& vm, bool testnet)
{
if(command_line::has_arg(vm, arg_extra_messages))
{
@ -198,7 +198,7 @@ namespace cryptonote
if(command_line::has_arg(vm, arg_start_mining))
{
if(!cryptonote::get_account_address_from_str(m_mine_address, command_line::get_arg(vm, arg_start_mining)))
if(!cryptonote::get_account_address_from_str(m_mine_address, testnet, command_line::get_arg(vm, arg_start_mining)))
{
LOG_ERROR("Target account address " << command_line::get_arg(vm, arg_start_mining) << " has wrong format, starting daemon canceled");
return false;

View File

@ -56,7 +56,7 @@ namespace cryptonote
public:
miner(i_miner_handler* phandler);
~miner();
bool init(const boost::program_options::variables_map& vm);
bool init(const boost::program_options::variables_map& vm, bool testnet);
static void init_options(boost::program_options::options_description& desc);
bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height);
bool on_block_chain_update();

View File

@ -218,10 +218,10 @@ int main(int argc, char* argv[])
cprotocol
, testnet_mode ? std::move(config::testnet::NETWORK_ID) : std::move(config::NETWORK_ID)
};
cryptonote::core_rpc_server rpc_server(ccore, p2psrv);
cryptonote::core_rpc_server rpc_server {ccore, p2psrv, testnet_mode};
cprotocol.set_p2p_endpoint(&p2psrv);
ccore.set_cryptonote_protocol(&cprotocol);
daemon_cmmands_handler dch(p2psrv);
daemon_cmmands_handler dch(p2psrv, testnet_mode);
//initialize objects
LOG_PRINT_L0("Initializing P2P server...");
@ -235,7 +235,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Protocol initialized OK");
LOG_PRINT_L0("Initializing core RPC server...");
res = rpc_server.init(vm, testnet_mode);
res = rpc_server.init(vm);
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize core RPC server.");
LOG_PRINT_GREEN("Core RPC server initialized OK on port: " << rpc_server.get_binded_port(), LOG_LEVEL_0);

View File

@ -50,7 +50,12 @@ class daemon_cmmands_handler
{
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& m_srv;
public:
daemon_cmmands_handler(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& srv):m_srv(srv)
daemon_cmmands_handler(
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& srv
, bool testnet
)
: m_srv(srv)
, m_testnet {testnet}
{
m_cmd_binder.set_handler("help", boost::bind(&daemon_cmmands_handler::help, this, _1), "Show this help");
m_cmd_binder.set_handler("print_pl", boost::bind(&daemon_cmmands_handler::print_pl, this, _1), "Print peer list");
@ -84,6 +89,7 @@ public:
private:
epee::srv_console_handlers_binder<nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> > > m_cmd_binder;
bool m_testnet;
//--------------------------------------------------------------------------------
std::string get_commands_str()
@ -368,7 +374,7 @@ private:
}
cryptonote::account_public_address adr;
if(!cryptonote::get_account_address_from_str(adr, args.front()))
if(!cryptonote::get_account_address_from_str(adr, m_testnet, args.front()))
{
std::cout << "target account address has wrong format" << std::endl;
return true;

View File

@ -72,15 +72,21 @@ namespace cryptonote
command_line::add_arg(desc, arg_testnet_rpc_bind_port);
}
//------------------------------------------------------------------------------------------------------------------------------
core_rpc_server::core_rpc_server(core& cr, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p):m_core(cr), m_p2p(p2p)
core_rpc_server::core_rpc_server(
core& cr
, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p
, bool testnet
)
: m_core(cr)
, m_p2p(p2p)
, m_testnet {testnet}
{}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::handle_command_line(
const boost::program_options::variables_map& vm
, bool testnet
)
{
auto p2p_bind_arg = testnet ? arg_testnet_rpc_bind_port : arg_rpc_bind_port;
auto p2p_bind_arg = m_testnet ? arg_testnet_rpc_bind_port : arg_rpc_bind_port;
m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip);
m_port = command_line::get_arg(vm, p2p_bind_arg);
@ -89,11 +95,10 @@ namespace cryptonote
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::init(
const boost::program_options::variables_map& vm
, bool testnet
)
{
m_net_server.set_threads_prefix("RPC");
bool r = handle_command_line(vm, testnet);
bool r = handle_command_line(vm);
CHECK_AND_ASSERT_MES(r, false, "Failed to process command line in core_rpc_server");
return epee::http_server_impl_base<core_rpc_server, connection_context>::init(m_port, m_bind_ip);
}
@ -302,7 +307,7 @@ namespace cryptonote
{
CHECK_CORE_READY();
account_public_address adr;
if(!get_account_address_from_str(adr, req.miner_address))
if(!get_account_address_from_str(adr, m_testnet, req.miner_address))
{
res.status = "Failed, wrong address";
return true;
@ -342,7 +347,7 @@ namespace cryptonote
res.speed = lMiner.get_speed();
res.threads_count = lMiner.get_threads_count();
const account_public_address& lMiningAdr = lMiner.get_mining_address();
res.address = get_account_address_as_str(lMiningAdr);
res.address = get_account_address_as_str(m_testnet, lMiningAdr);
}
res.status = CORE_RPC_STATUS_OK;
@ -426,7 +431,7 @@ namespace cryptonote
cryptonote::account_public_address acc = AUTO_VAL_INIT(acc);
if(!req.wallet_address.size() || !cryptonote::get_account_address_from_str(acc, req.wallet_address))
if(!req.wallet_address.size() || !cryptonote::get_account_address_from_str(acc, m_testnet, req.wallet_address))
{
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_WALLET_ADDRESS;
error_resp.message = "Failed to parse wallet address";

View File

@ -49,12 +49,15 @@ namespace cryptonote
public:
typedef epee::net_utils::connection_context_base connection_context;
core_rpc_server(core& cr, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p);
core_rpc_server(
core& cr
, nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& p2p
, bool testnet
);
static void init_options(boost::program_options::options_description& desc);
bool init(
const boost::program_options::variables_map& vm
, bool testnet
);
private:
@ -110,7 +113,6 @@ namespace cryptonote
//-----------------------
bool handle_command_line(
const boost::program_options::variables_map& vm
, bool testnet
);
bool check_core_busy();
bool check_core_ready();
@ -123,5 +125,6 @@ namespace cryptonote
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& m_p2p;
std::string m_port;
std::string m_bind_ip;
bool m_testnet;
};
}

View File

@ -441,7 +441,9 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas
try
{
recovery_val = m_wallet->generate(wallet_file, password, recovery_key, recover, two_random);
message_writer(epee::log_space::console_color_white, true) << "Generated new wallet: " << m_wallet->get_account().get_public_address_str() << std::endl << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key);
message_writer(epee::log_space::console_color_white, true) << "Generated new wallet: "
<< m_wallet->get_account().get_public_address_str(m_wallet->testnet()) << std::endl << "view key: "
<< string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key);
}
catch (const std::exception& e)
{
@ -487,7 +489,8 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa
try
{
m_wallet->load(m_wallet_file, password);
message_writer(epee::log_space::console_color_white, true) << "Opened wallet: " << m_wallet->get_account().get_public_address_str();
message_writer(epee::log_space::console_color_white, true) << "Opened wallet: "
<< m_wallet->get_account().get_public_address_str(m_wallet->testnet());
}
catch (const std::exception& e)
{
@ -548,7 +551,7 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args)
return true;
COMMAND_RPC_START_MINING::request req;
req.miner_address = m_wallet->get_account().get_public_address_str();
req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->testnet());
bool ok = true;
size_t max_mining_threads_count = (std::max)(std::thread::hardware_concurrency(), static_cast<unsigned>(2));
@ -905,7 +908,7 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
for (size_t i = 0; i < local_args.size(); i += 2)
{
cryptonote::tx_destination_entry de;
if(!get_account_address_from_str(de.addr, local_args[i]))
if(!get_account_address_from_str(de.addr, m_wallet->testnet(), local_args[i]))
{
fail_msg_writer() << "wrong address: " << local_args[i];
return true;
@ -1035,7 +1038,7 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
//----------------------------------------------------------------------------------------------------
bool simple_wallet::run()
{
std::string addr_start = m_wallet->get_account().get_public_address_str().substr(0, 6);
std::string addr_start = m_wallet->get_account().get_public_address_str(m_wallet->testnet()).substr(0, 6);
return m_cmd_binder.run_handling("[wallet " + addr_start + "]: ", "");
}
//----------------------------------------------------------------------------------------------------
@ -1047,7 +1050,7 @@ void simple_wallet::stop()
//----------------------------------------------------------------------------------------------------
bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
success_msg_writer() << m_wallet->get_account().get_public_address_str();
success_msg_writer() << m_wallet->get_account().get_public_address_str(m_wallet->testnet());
return true;
}
//----------------------------------------------------------------------------------------------------

View File

@ -496,7 +496,7 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri
bool r = store_keys(m_keys_file, password);
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, m_keys_file);
r = file_io_utils::save_string_to_file(m_wallet_file + ".address.txt", m_account.get_public_address_str());
r = file_io_utils::save_string_to_file(m_wallet_file + ".address.txt", m_account.get_public_address_str(m_testnet));
if(!r) LOG_PRINT_RED_L0("String with address text not saved");
cryptonote::block b;
@ -562,7 +562,7 @@ void wallet2::load(const std::string& wallet_, const std::string& password)
THROW_WALLET_EXCEPTION_IF(e || !exists, error::file_not_found, m_keys_file);
load_keys(m_keys_file, password);
LOG_PRINT_L0("Loaded wallet keys file, with public address: " << m_account.get_public_address_str());
LOG_PRINT_L0("Loaded wallet keys file, with public address: " << m_account.get_public_address_str(m_testnet));
//keys loaded ok!
//try to load wallet file. but even if we failed, it is not big problem

View File

@ -158,6 +158,8 @@ namespace tools
void refresh(uint64_t start_height, size_t & blocks_fetched, bool& received_money);
bool refresh(size_t & blocks_fetched, bool& received_money, bool& ok);
bool testnet() { return m_testnet; }
uint64_t balance();
uint64_t unlocked_balance();
template<typename T>
@ -360,7 +362,7 @@ namespace tools
{
THROW_WALLET_EXCEPTION_IF(0 == dt.amount, error::zero_destination);
needed_money += dt.amount;
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, fee);
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, fee, m_testnet);
}
// randomly select inputs for transaction
@ -465,7 +467,7 @@ namespace tools
}
bool r = cryptonote::construct_tx(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(m_upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, m_upper_transaction_size_limit);
std::string key_images;

View File

@ -376,11 +376,18 @@ namespace tools
typedef std::vector<cryptonote::tx_source_entry> sources_t;
typedef std::vector<cryptonote::tx_destination_entry> destinations_t;
explicit tx_not_constructed(std::string&& loc, const sources_t& sources, const destinations_t& destinations, uint64_t unlock_time)
: transfer_error(std::move(loc), "transaction was not constructed")
, m_sources(sources)
, m_destinations(destinations)
, m_unlock_time(unlock_time)
explicit tx_not_constructed(
std::string && loc
, sources_t const & sources
, destinations_t const & destinations
, uint64_t unlock_time
, bool testnet
)
: transfer_error {std::move(loc), "transaction was not constructed"}
, m_sources {sources}
, m_destinations {destinations}
, m_unlock_time {unlock_time}
, m_testnet {testnet}
{
}
@ -414,7 +421,7 @@ namespace tools
for (size_t i = 0; i < m_destinations.size(); ++i)
{
const cryptonote::tx_destination_entry& dst = m_destinations[i];
ss << "\n " << i << ": " << cryptonote::get_account_address_as_str(dst.addr) << " " <<
ss << "\n " << i << ": " << cryptonote::get_account_address_as_str(m_testnet, dst.addr) << " " <<
cryptonote::print_money(dst.amount);
}
@ -427,6 +434,7 @@ namespace tools
sources_t m_sources;
destinations_t m_destinations;
uint64_t m_unlock_time;
bool m_testnet;
};
//----------------------------------------------------------------------------------------------------
struct tx_rejected : public transfer_error
@ -457,10 +465,16 @@ namespace tools
//----------------------------------------------------------------------------------------------------
struct tx_sum_overflow : public transfer_error
{
explicit tx_sum_overflow(std::string&& loc, const std::vector<cryptonote::tx_destination_entry>& destinations, uint64_t fee)
: transfer_error(std::move(loc), "transaction sum + fee exceeds " + cryptonote::print_money(std::numeric_limits<uint64_t>::max()))
, m_destinations(destinations)
, m_fee(fee)
explicit tx_sum_overflow(
std::string && loc
, const std::vector<cryptonote::tx_destination_entry>& destinations
, uint64_t fee
, bool testnet
)
: transfer_error {std::move(loc), "transaction sum + fee exceeds " + cryptonote::print_money(std::numeric_limits<uint64_t>::max())}
, m_destinations {destinations}
, m_fee {fee}
, m_testnet {testnet}
{
}
@ -475,7 +489,7 @@ namespace tools
", destinations:";
for (const auto& dst : m_destinations)
{
ss << '\n' << cryptonote::print_money(dst.amount) << " -> " << cryptonote::get_account_address_as_str(dst.addr);
ss << '\n' << cryptonote::print_money(dst.amount) << " -> " << cryptonote::get_account_address_as_str(m_testnet, dst.addr);
}
return ss.str();
}
@ -483,6 +497,7 @@ namespace tools
private:
std::vector<cryptonote::tx_destination_entry> m_destinations;
uint64_t m_fee;
bool m_testnet;
};
//----------------------------------------------------------------------------------------------------
struct tx_too_big : public transfer_error

View File

@ -101,7 +101,7 @@ namespace tools
{
try
{
res.address = m_wallet.get_account().get_public_address_str();
res.address = m_wallet.get_account().get_public_address_str(m_wallet.testnet());
}
catch (std::exception& e)
{
@ -118,7 +118,7 @@ namespace tools
for (auto it = destinations.begin(); it != destinations.end(); it++)
{
cryptonote::tx_destination_entry de;
if(!get_account_address_from_str(de.addr, it->address))
if(!get_account_address_from_str(de.addr, m_wallet.testnet(), it->address))
{
er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
er.message = std::string("WALLET_RPC_ERROR_CODE_WRONG_ADDRESS: ") + it->address;

View File

@ -54,7 +54,7 @@ bool test_transaction_generation_and_ring_signature()
account_base miner_acc6;
miner_acc6.generate();
std::string add_str = miner_acc3.get_public_address_str();
std::string add_str = miner_acc3.get_public_address_str(false);
account_base rv_acc;
@ -150,7 +150,7 @@ bool test_block_creation()
uint64_t vszs[] = {80,476,476,475,475,474,475,474,474,475,472,476,476,475,475,474,475,474,474,475,472,476,476,475,475,474,475,474,474,475,9391,476,476,475,475,474,475,8819,8301,475,472,4302,5316,14347,16620,19583,19403,19728,19442,19852,19015,19000,19016,19795,19749,18087,19787,19704,19750,19267,19006,19050,19445,19407,19522,19546,19788,19369,19486,19329,19370,18853,19600,19110,19320,19746,19474,19474,19743,19494,19755,19715,19769,19620,19368,19839,19532,23424,28287,30707};
std::vector<uint64_t> szs(&vszs[0], &vszs[90]);
account_public_address adr;
bool r = get_account_address_from_str(adr, "0099be99c70ef10fd534c43c88e9d13d1c8853213df7e362afbec0e4ee6fec4948d0c190b58f4b356cd7feaf8d9d0a76e7c7e5a9a0a497a6b1faf7a765882dd08ac2");
bool r = get_account_address_from_str(adr, false, "0099be99c70ef10fd534c43c88e9d13d1c8853213df7e362afbec0e4ee6fec4948d0c190b58f4b356cd7feaf8d9d0a76e7c7e5a9a0a497a6b1faf7a765882dd08ac2");
CHECK_AND_ASSERT_MES(r, false, "failed to import");
block b;
r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, b.miner_tx, blobdata(), 11);

View File

@ -54,7 +54,7 @@ TEST(Transfers, Transfers)
miner.generate();
ASSERT_TRUE(miner.init());
ASSERT_TRUE(miner.store("miner.b2wallet"));
cout << "miner: " << miner.get_account().get_public_address_str() << endl;
cout << "miner: " << miner.get_account().get_public_address_str(false) << endl;
for (int i = 0; i < ACCS; i++) {
ostringstream s;
@ -69,7 +69,7 @@ TEST(Transfers, Transfers)
{
COMMAND_RPC_START_MINE::request req;
req.miner_address = miner.get_account().get_public_address_str();
req.miner_address = miner.get_account().get_public_address_str(false);
req.threads_count = 1;
COMMAND_RPC_START_MINE::response res;
bool r = net_utils::http::invoke_http_json_remote_command(daemon_address + "/start_mine", req, res, http_client);

View File

@ -151,8 +151,8 @@ bool transactions_flow_test(std::string& working_folder,
w2.init(daemon_addr_b);
LOG_PRINT_GREEN("Using wallets: " << ENDL
<< "Source: " << w1.get_account().get_public_address_str() << ENDL << "Path: " << working_folder + "/" + path_source_wallet << ENDL
<< "Target: " << w2.get_account().get_public_address_str() << ENDL << "Path: " << working_folder + "/" + path_terget_wallet, LOG_LEVEL_1);
<< "Source: " << w1.get_account().get_public_address_str(false) << ENDL << "Path: " << working_folder + "/" + path_source_wallet << ENDL
<< "Target: " << w2.get_account().get_public_address_str(false) << ENDL << "Path: " << working_folder + "/" + path_terget_wallet, LOG_LEVEL_1);
//lets do some money
epee::net_utils::http::http_simple_client http_client;
@ -163,7 +163,7 @@ bool transactions_flow_test(std::string& working_folder,
COMMAND_RPC_START_MINING::request daemon_req = AUTO_VAL_INIT(daemon_req);
COMMAND_RPC_START_MINING::response daemon_rsp = AUTO_VAL_INIT(daemon_rsp);
daemon_req.miner_address = w1.get_account().get_public_address_str();
daemon_req.miner_address = w1.get_account().get_public_address_str(false);
daemon_req.threads_count = 9;
r = net_utils::invoke_http_json_remote_command2(daemon_addr_a + "/start_mining", daemon_req, daemon_rsp, http_client, 10000);
CHECK_AND_ASSERT_MES(r, false, "failed to get getrandom_outs");

View File

@ -473,14 +473,14 @@ TEST(get_account_address_as_str, works_correctly)
{
cryptonote::account_public_address addr;
ASSERT_TRUE(serialization::parse_binary(test_serialized_keys, addr));
std::string addr_str = cryptonote::get_account_address_as_str(addr);
std::string addr_str = cryptonote::get_account_address_as_str(false, addr);
ASSERT_EQ(addr_str, test_keys_addr_str);
}
TEST(get_account_address_from_str, handles_valid_address)
{
cryptonote::account_public_address addr;
ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, test_keys_addr_str));
ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, false, test_keys_addr_str));
std::string blob;
ASSERT_TRUE(serialization::dump_binary(addr, blob));
@ -493,7 +493,7 @@ TEST(get_account_address_from_str, fails_on_invalid_address_format)
std::string addr_str = test_keys_addr_str;
addr_str[0] = '0';
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, addr_str));
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_prefix)
@ -501,7 +501,7 @@ TEST(get_account_address_from_str, fails_on_invalid_address_prefix)
std::string addr_str = base58::encode_addr(0, test_serialized_keys);
cryptonote::account_public_address addr;
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, addr_str));
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_content)
@ -509,7 +509,7 @@ TEST(get_account_address_from_str, fails_on_invalid_address_content)
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, test_serialized_keys.substr(1));
cryptonote::account_public_address addr;
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, addr_str));
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_spend_key)
@ -519,7 +519,7 @@ TEST(get_account_address_from_str, fails_on_invalid_address_spend_key)
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, serialized_keys_copy);
cryptonote::account_public_address addr;
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, addr_str));
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
}
TEST(get_account_address_from_str, fails_on_invalid_address_view_key)
@ -529,11 +529,11 @@ TEST(get_account_address_from_str, fails_on_invalid_address_view_key)
std::string addr_str = base58::encode_addr(config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX, serialized_keys_copy);
cryptonote::account_public_address addr;
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, addr_str));
ASSERT_FALSE(cryptonote::get_account_address_from_str(addr, false, addr_str));
}
TEST(get_account_address_from_str, parses_old_address_format)
{
cryptonote::account_public_address addr;
ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, "002391bbbb24dea6fd95232e97594a27769d0153d053d2102b789c498f57a2b00b69cd6f2f5c529c1660f2f4a2b50178d6640c20ce71fe26373041af97c5b10236fc"));
ASSERT_TRUE(cryptonote::get_account_address_from_str(addr, false, "002391bbbb24dea6fd95232e97594a27769d0153d053d2102b789c498f57a2b00b69cd6f2f5c529c1660f2f4a2b50178d6640c20ce71fe26373041af97c5b10236fc"));
}