Skip to content

Commit

Permalink
fixup loki stagenet changes after upstream merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tewinget committed Apr 10, 2018
1 parent dcd6e45 commit c6549bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ namespace config
boost::uuids::uuid const NETWORK_ID = { {
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12
} }; // Bender's daydream
std::string const GENESIS_TX = "013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
std::string const GENESIS_TX = "023c01ff000380808d93f5d771027389ebfc2065e669080d96f3b5706958d485d25cf2031c6ecc30a17191fc4fe08080b4ccd4dfc60302a45f41e3ebfca05a9723e6cbbba2caffbd767153d1e1a85230bbcfb8b7482388808088fccdbcc3230252635354495b1282b6510b03fc484884ba82f2a574a59bdbaf749d4a75ea6603210177fb23a01548df63e87a60f8fb41d4bbe293c3d6b2c128dde2d37b27958bdd2f00";
uint32_t const GENESIS_NONCE = 10002;

std::string const GOVERNANCE_WALLET_ADDRESS = "T6U5dnmhyw1XsDryZUZL4hAwkNDYahFLEbhyfipTJ2ZZLV1Epm5zHTf6SQzxre9V8R9zjSPN6WWiT9adBQYt7Wut2xjon6dgT";
std::string const GOVERNANCE_WALLET_ADDRESS = "52hBAREiNay8bH6JCfWrGdDM3cV6yHMLpcKFnVfnqPcVUrKGLbJCmkuUzJZqLfjzrMRYQgUsoHTuuMA1Z7QKvxFVANKHdGt";
}
}

Expand Down
20 changes: 6 additions & 14 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,8 @@ static const struct {
uint8_t threshold;
time_t time;
} stagenet_hard_forks[] = {
// version 1 from the start of the blockchain
{ 1, 1, 0, 1341378000 },

// versions 2-7 in rapid succession from March 13th, 2018
{ 2, 32000, 0, 1521000000 },
{ 3, 33000, 0, 1521120000 },
{ 4, 34000, 0, 1521240000 },
{ 5, 35000, 0, 1521360000 },
{ 6, 36000, 0, 1521480000 },
{ 7, 37000, 0, 1521600000 },
// version 7 from the start of the blockchain, inhereted from Loki testnet
{ 7, 1, 0, 1341378000 },
};

//------------------------------------------------------------------
Expand Down Expand Up @@ -323,11 +315,11 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
if (m_hardfork == nullptr)
{
if (m_nettype == FAKECHAIN || m_nettype == STAGENET)
m_hardfork = new HardFork(*db, 1, 0);
m_hardfork = new HardFork(*db, 7, 0);
else if (m_nettype == TESTNET)
m_hardfork = new HardFork(*db, 1, testnet_hard_fork_version_1_till);
m_hardfork = new HardFork(*db, 7, testnet_hard_fork_version_1_till);
else
m_hardfork = new HardFork(*db, 1, mainnet_hard_fork_version_1_till);
m_hardfork = new HardFork(*db, 7, mainnet_hard_fork_version_1_till);
}
if (m_nettype == FAKECHAIN)
{
Expand Down Expand Up @@ -1055,7 +1047,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
return false;
}

if (!validate_governance_reward_key(m_db->height(), governance_wallet_address_str, b.miner_tx.vout.size() - 1, boost::get<txout_to_key>(b.miner_tx.vout.back().target).key))
if (!validate_governance_reward_key(m_db->height(), governance_wallet_address_str, b.miner_tx.vout.size() - 1, boost::get<txout_to_key>(b.miner_tx.vout.back().target).key, m_nettype))
{
MERROR("Governance reward public key incorrect.");
return false;
Expand Down
28 changes: 21 additions & 7 deletions src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,25 @@ namespace cryptonote
return true;
}

bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key)
bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key, const cryptonote::network_type nettype)
{
keypair gov_key = get_deterministic_keypair_from_height(height);

cryptonote::address_parse_info governance_wallet_address;
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str);
switch (nettype)
{
case STAGENET:
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::STAGENET, governance_wallet_address_str);
break;
case TESTNET:
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::TESTNET, governance_wallet_address_str);
break;
case MAINNET:
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str);
break;
default:
return false;
}

crypto::public_key correct_key;

Expand Down Expand Up @@ -231,23 +244,24 @@ namespace cryptonote
if (already_generated_coins != 0)
{
std::string governance_wallet_address_str;

cryptonote::address_parse_info governance_wallet_address;

switch (nettype)
{
case STAGENET:
governance_wallet_address_str = ::config::stagenet::GOVERNANCE_WALLET_ADDRESS;
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::STAGENET, ::config::stagenet::GOVERNANCE_WALLET_ADDRESS);
break;
case TESTNET:
governance_wallet_address_str = ::config::testnet::GOVERNANCE_WALLET_ADDRESS;
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::TESTNET, ::config::testnet::GOVERNANCE_WALLET_ADDRESS);
break;
case MAINNET:
governance_wallet_address_str = ::config::GOVERNANCE_WALLET_ADDRESS;
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, ::config::GOVERNANCE_WALLET_ADDRESS);
break;
default:
return false;
}

cryptonote::address_parse_info governance_wallet_address;
cryptonote::get_account_address_from_str(governance_wallet_address, cryptonote::MAINNET, governance_wallet_address_str);

crypto::public_key out_eph_public_key = AUTO_VAL_INIT(out_eph_public_key);

Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_tx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace cryptonote

bool get_deterministic_output_key(const account_public_address& address, const keypair& tx_key, size_t output_index, crypto::public_key& output_key);

bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key);
bool validate_governance_reward_key(uint64_t height, const std::string& governance_wallet_address_str, size_t output_index, const crypto::public_key& output_key, const cryptonote::network_type nettype);