Skip to content

Commit

Permalink
Add separate genesis tx for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
who-biz committed Jan 16, 2020
1 parent 09b0234 commit ca4ae10
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1

#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 /* by default, blocks ids count in synchronizing */
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 /* by default, blocks count in blocks downloading */
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 100 /* by default, blocks count in blocks downloading */

#define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) /* seconds, three days */
#define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 /* seconds, one week */
Expand Down Expand Up @@ -173,6 +173,8 @@ namespace config
boost::uuids::uuid const NETWORK_ID = { {
0x22 ,0x36, 0xF1, 0x22 , 0x54, 0x86 , 0x37, 0xFF, 0xAB, 0x89, 0x01, 0x92, 0xAA, 0xBC, 0x2F, 0x16
} };
std::string const GENESIS_TX = "011901ff0001ffffffffffff0102bca7c97f7074ea888eac572fda0964cc864baf7bc07d6cecc052728039009d7621017133140c2abc1825f8d411db7bee4379a2a0f21b7af60e44ed7f07f9e66ccd8800";
uint32_t const GENESIS_NONCE = 10001;
}

namespace stagenet
Expand Down
4 changes: 2 additions & 2 deletions src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,13 @@ namespace cryptonote
return construct_tx_and_get_tx_key(sender_account_keys, subaddresses, sources, destinations_copy, change_addr, extra, tx, unlock_time, tx_key, additional_tx_keys, false, false, NULL);
}
//---------------------------------------------------------------
bool generate_genesis_block(block& bl)
bool generate_genesis_block(block& bl, network_type nettype)
{
//genesis block
bl = boost::value_initialized<block>();

blobdata tx_bl;
bool r = string_tools::parse_hexstr_to_binbuff(config::GENESIS_TX, tx_bl);
bool r = string_tools::parse_hexstr_to_binbuff(nettype == cryptonote::MAINNET ? config::GENESIS_TX : config::testnet::GENESIS_TX, tx_bl);
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
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 @@ -94,7 +94,7 @@ namespace cryptonote
bool construct_tx_with_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, bool bulletproof = false, rct::multisig_out *msout = NULL);
bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, bool bulletproof = false, rct::multisig_out *msout = NULL);

bool generate_genesis_block(block& bl);
bool generate_genesis_block(block& bl, network_type nettype);

}

Expand Down
24 changes: 12 additions & 12 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,7 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
}

cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));

Expand Down Expand Up @@ -3062,7 +3062,7 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const epee::wip
}

cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));

Expand Down Expand Up @@ -3127,7 +3127,7 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
}

cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));

Expand Down Expand Up @@ -3177,7 +3177,7 @@ void wallet2::generate(const std::string& wallet_, const epee::wipeable_string&
}

cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));

Expand Down Expand Up @@ -3217,7 +3217,7 @@ void wallet2::restore(const std::string& wallet_, const epee::wipeable_string& p
if(!r) MERROR("String with address text not saved");
}
cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));
if (!wallet_.empty()) {
Expand Down Expand Up @@ -3313,7 +3313,7 @@ std::string wallet2::make_multisig(const epee::wipeable_string &password,
}

cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_blockchain.push_back(get_block_hash(b));
add_subaddress_account(tr("Primary account"));

Expand Down Expand Up @@ -3796,7 +3796,7 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
}

cryptonote::block genesis;
generate_genesis(genesis);
generate_genesis(genesis, m_nettype);
crypto::hash genesis_hash = get_block_hash(genesis);

if (m_blockchain.empty())
Expand Down Expand Up @@ -4184,7 +4184,7 @@ void wallet2::rescan_blockchain(bool refresh)
clear();

cryptonote::block genesis;
generate_genesis(genesis);
generate_genesis(genesis, m_nettype);
crypto::hash genesis_hash = get_block_hash(genesis);
m_blockchain.push_back(genesis_hash);
add_subaddress_account(tr("Primary account"));
Expand Down Expand Up @@ -5414,7 +5414,7 @@ bool wallet2::set_ring_database(const std::string &filename)
try
{
cryptonote::block b;
generate_genesis(b);
generate_genesis(b, m_nettype);
m_ringdb.reset(new tools::ringdb(m_ring_database, epee::string_tools::pod_to_hex(get_block_hash(b))));
}
catch (const std::exception &e)
Expand Down Expand Up @@ -8963,7 +8963,7 @@ void wallet2::import_blockchain(const std::tuple<size_t, crypto::hash, std::vect
m_blockchain.push_back(b);
}
cryptonote::block genesis;
generate_genesis(genesis);
generate_genesis(genesis, m_nettype);
crypto::hash genesis_hash = get_block_hash(genesis);
check_genesis(genesis_hash);
m_local_bc_height = m_blockchain.size();
Expand Down Expand Up @@ -9676,7 +9676,7 @@ uint64_t wallet2::get_segregation_fork_height() const
return SEGREGATION_FORK_HEIGHT;
}
//----------------------------------------------------------------------------------------------------
void wallet2::generate_genesis(cryptonote::block& b) const {
cryptonote::generate_genesis_block(b);
void wallet2::generate_genesis(cryptonote::block& b, cryptonote::network_type const& m_nettype) const {
cryptonote::generate_genesis_block(b, m_nettype);
}
}
2 changes: 1 addition & 1 deletion src/wallet/wallet2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ namespace tools
void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
void process_outgoing(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices);
void add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amount_in, const std::vector<cryptonote::tx_destination_entry> &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices);
void generate_genesis(cryptonote::block& b) const;
void generate_genesis(cryptonote::block& b, cryptonote::network_type const& nettype) const;
void check_genesis(const crypto::hash& genesis_hash) const; //throws
bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
crypto::hash get_payment_id(const pending_tx &ptx) const;
Expand Down

0 comments on commit ca4ae10

Please sign in to comment.