aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorZachary Michaels <mikezackles@gmail.com>2014-09-09 10:58:53 -0400
committerRiccardo Spagni <ric@spagni.net>2014-09-15 15:54:59 +0200
commitd03308734b1487540af062ab50c94cc7bb3e668e (patch)
tree59b26c94f7449bb6e57a9c4c7a0ec3983c1d2feb /src/cryptonote_core
parentAdd testnet seed nodes (diff)
downloadmonero-d03308734b1487540af062ab50c94cc7bb3e668e.tar.xz
Separate testnet address prefix
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/account.cpp4
-rw-r--r--src/cryptonote_core/account.h2
-rw-r--r--src/cryptonote_core/cryptonote_basic_impl.cpp23
-rw-r--r--src/cryptonote_core/cryptonote_basic_impl.h14
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp2
-rw-r--r--src/cryptonote_core/miner.cpp4
-rw-r--r--src/cryptonote_core/miner.h2
7 files changed, 37 insertions, 14 deletions
diff --git a/src/cryptonote_core/account.cpp b/src/cryptonote_core/account.cpp
index d07dad33f..36043238d 100644
--- a/src/cryptonote_core/account.cpp
+++ b/src/cryptonote_core/account.cpp
@@ -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);
}
//-----------------------------------------------------------------
}
diff --git a/src/cryptonote_core/account.h b/src/cryptonote_core/account.h
index 06bd700a9..dd6618542 100644
--- a/src/cryptonote_core/account.h
+++ b/src/cryptonote_core/account.h
@@ -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; }
diff --git a/src/cryptonote_core/cryptonote_basic_impl.cpp b/src/cryptonote_core/cryptonote_basic_impl.cpp
index 398c63443..9cec666f2 100644
--- a/src/cryptonote_core/cryptonote_basic_impl.cpp
+++ b/src/cryptonote_core/cryptonote_basic_impl.cpp
@@ -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;
}
diff --git a/src/cryptonote_core/cryptonote_basic_impl.h b/src/cryptonote_core/cryptonote_basic_impl.h
index a3184378e..ddef677cb 100644
--- a/src/cryptonote_core/cryptonote_basic_impl.h
+++ b/src/cryptonote_core/cryptonote_basic_impl.h
@@ -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);
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 72e5ee209..964d61e2f 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -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();
diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp
index 81dc4a692..b2adfe39c 100644
--- a/src/cryptonote_core/miner.cpp
+++ b/src/cryptonote_core/miner.cpp
@@ -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;
diff --git a/src/cryptonote_core/miner.h b/src/cryptonote_core/miner.h
index a96d42d75..44844428c 100644
--- a/src/cryptonote_core/miner.h
+++ b/src/cryptonote_core/miner.h
@@ -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();