mirror of
https://github.com/monero-project/monero.git
synced 2025-07-30 05:08:43 -04:00
Separate testnet address prefix
This commit is contained in:
parent
ee1bacc64f
commit
d03308734b
21 changed files with 126 additions and 69 deletions
|
@ -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);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue