diff options
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.cpp | 43 | ||||
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 230 | ||||
-rw-r--r-- | src/common/command_line.cpp | 5 | ||||
-rw-r--r-- | src/common/command_line.h | 1 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 15 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 11 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 1 | ||||
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 242 | ||||
-rw-r--r-- | tests/core_tests/chaingen.h | 7 | ||||
-rw-r--r-- | tests/core_tests/ring_signature_1.cpp | 16 | ||||
-rw-r--r-- | tests/unit_tests/block_reward.cpp | 30 | ||||
-rw-r--r-- | tests/unit_tests/checkpoints.cpp | 2 |
14 files changed, 361 insertions, 246 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index ce355ccde..07cb622a7 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -759,7 +759,7 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags) } else { - if (!boost::filesystem::create_directory(direc)) + if (!boost::filesystem::create_directories(direc)) throw0(DB_OPEN_FAILURE(std::string("Failed to create directory ").append(filename).c_str())); } @@ -1042,7 +1042,46 @@ void BlockchainBDB::sync() void BlockchainBDB::reset() { LOG_PRINT_L3("BlockchainBDB::" << __func__); - // TODO: this + check_open(); + + bdb_txn_safe txn; + if (m_env->txn_begin(NULL, txn, 0)) + throw0(DB_ERROR("Failed to create a transaction for the db")); + m_write_txn = &txn; + try + { + uint32_t count; + + m_blocks->truncate(*m_write_txn, &count, 0); + m_block_heights->truncate(*m_write_txn, &count, 0); + m_block_hashes->truncate(*m_write_txn, &count, 0); + m_block_timestamps->truncate(*m_write_txn, &count, 0); + m_block_sizes->truncate(*m_write_txn, &count, 0); + m_block_diffs->truncate(*m_write_txn, &count, 0); + m_block_coins->truncate(*m_write_txn, &count, 0); + + m_txs->truncate(*m_write_txn, &count, 0); + m_tx_unlocks->truncate(*m_write_txn, &count, 0); + m_tx_heights->truncate(*m_write_txn, &count, 0); + m_tx_outputs->truncate(*m_write_txn, &count, 0); + + m_output_txs->truncate(*m_write_txn, &count, 0); + m_output_indices->truncate(*m_write_txn, &count, 0); + m_output_amounts->truncate(*m_write_txn, &count, 0); + m_output_keys->truncate(*m_write_txn, &count, 0); + + m_spent_keys->truncate(*m_write_txn, &count, 0); + + m_hf_starting_heights->truncate(*m_write_txn, &count, 0); + m_hf_versions->truncate(*m_write_txn, &count, 0); + + m_properties->truncate(*m_write_txn, &count, 0); + } + catch (const std::exception& e) + { + throw0(DB_ERROR(std::string("Failed to reset database: ").append(e.what()).c_str())); + } + m_write_txn = NULL; } std::vector<std::string> BlockchainBDB::get_filenames() const diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index de8066123..b941fe6b1 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -208,6 +208,12 @@ inline void lmdb_db_open(MDB_txn* txn, const char* name, int flags, MDB_dbi& dbi throw0(cryptonote::DB_OPEN_FAILURE(error_string.c_str())); } +const std::string lmdb_error(const std::string& error_string, int mdb_res) +{ + const std::string full_string = error_string + mdb_strerror(mdb_res); + return full_string; +} + } // anonymous namespace namespace cryptonote @@ -943,7 +949,7 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) } else { - if (!boost::filesystem::create_directory(direc)) + if (!boost::filesystem::create_directories(direc)) throw0(DB_OPEN_FAILURE(std::string("Failed to create directory ").append(filename).c_str())); } @@ -994,8 +1000,8 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) // get a read/write MDB_txn, depending on mdb_flags mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, txn_flags, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, txn_flags, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); // open necessary databases, and set properties as needed // uses macros to avoid having to change things too many places @@ -1159,7 +1165,33 @@ void BlockchainLMDB::sync() void BlockchainLMDB::reset() { LOG_PRINT_L3("BlockchainLMDB::" << __func__); - // TODO: this + check_open(); + + mdb_txn_safe txn; + if (mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR("Failed to create a transaction for the db")); + mdb_drop(txn, m_blocks, 0); + mdb_drop(txn, m_block_timestamps, 0); + mdb_drop(txn, m_block_heights, 0); + mdb_drop(txn, m_block_hashes, 0); + mdb_drop(txn, m_block_sizes, 0); + mdb_drop(txn, m_block_diffs, 0); + mdb_drop(txn, m_block_coins, 0); + mdb_drop(txn, m_txs, 0); + mdb_drop(txn, m_tx_unlocks, 0); + mdb_drop(txn, m_tx_heights, 0); + mdb_drop(txn, m_tx_outputs, 0); + mdb_drop(txn, m_output_txs, 0); + mdb_drop(txn, m_output_indices, 0); + mdb_drop(txn, m_output_amounts, 0); + mdb_drop(txn, m_output_keys, 0); + mdb_drop(txn, m_spent_keys, 0); + mdb_drop(txn, m_hf_starting_heights, 0); + mdb_drop(txn, m_hf_versions, 0); + mdb_drop(txn, m_properties, 0); + txn.commit(); + m_height = 0; + m_num_outputs = 0; } std::vector<std::string> BlockchainLMDB::get_filenames() const @@ -1206,8 +1238,8 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) const check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<crypto::hash> key(h); MDB_val result; @@ -1238,9 +1270,10 @@ uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<crypto::hash> key(h); MDB_val result; @@ -1250,8 +1283,9 @@ uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a block height from the db")); + ret = *(const uint64_t *)result.mv_data; txn.commit(); - return *(const uint64_t*)result.mv_data; + return ret; } block_header BlockchainLMDB::get_block_header(const crypto::hash& h) const @@ -1269,8 +1303,8 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) const check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<uint64_t> key(height); MDB_val result; @@ -1282,8 +1316,6 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) const else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a block from the db")); - txn.commit(); - blobdata bd; bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size); @@ -1291,6 +1323,8 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) const if (!parse_and_validate_block_from_blob(bd, b)) throw0(DB_ERROR("Failed to parse block from blob retrieved from the db")); + txn.commit(); + return b; } @@ -1299,14 +1333,15 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<uint64_t> key(height); MDB_val result; @@ -1318,9 +1353,10 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a timestamp from the db")); + ret = *(const uint64_t *)result.mv_data; if (! m_batch_active) txn.commit(); - return *(const uint64_t*)result.mv_data; + return ret; } uint64_t BlockchainLMDB::get_top_block_timestamp() const @@ -1348,10 +1384,11 @@ size_t BlockchainLMDB::get_block_size(const uint64_t& height) const txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } + size_t ret; MDB_val_copy<uint64_t> key(height); MDB_val result; auto get_result = mdb_get(*txn_ptr, m_block_sizes, &key, &result); @@ -1362,9 +1399,10 @@ size_t BlockchainLMDB::get_block_size(const uint64_t& height) const else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a block size from the db")); + ret = *(const size_t *)result.mv_data; if (! m_batch_active) txn.commit(); - return *(const size_t*)result.mv_data; + return ret; } difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& height) const @@ -1372,14 +1410,15 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " height: " << height); check_open(); + difficulty_type ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<uint64_t> key(height); MDB_val result; @@ -1391,9 +1430,10 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a cumulative difficulty from the db")); + ret = *(difficulty_type*)result.mv_data; if (! m_batch_active) txn.commit(); - return *(difficulty_type*)result.mv_data; + return ret; } difficulty_type BlockchainLMDB::get_block_difficulty(const uint64_t& height) const @@ -1418,14 +1458,15 @@ uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& heigh LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<uint64_t> key(height); @@ -1438,9 +1479,10 @@ uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& heigh else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a total generated coins from the db")); + ret = *(const uint64_t*)result.mv_data; if (! m_batch_active) txn.commit(); - return *(const uint64_t*)result.mv_data; + return ret; } crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) const @@ -1448,14 +1490,15 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + crypto::hash ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<uint64_t> key(height); @@ -1469,9 +1512,10 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) throw0(DB_ERROR(std::string("Error attempting to retrieve a block hash from the db: "). append(mdb_strerror(get_result)).c_str())); + ret = *(crypto::hash*)result.mv_data; if (! m_batch_active) txn.commit(); - return *(crypto::hash*)result.mv_data; + return ret; } std::vector<block> BlockchainLMDB::get_blocks_range(const uint64_t& h1, const uint64_t& h2) const @@ -1547,8 +1591,8 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<crypto::hash> key(h); @@ -1558,10 +1602,10 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const auto get_result = mdb_get(*txn_ptr, m_txs, &key, &result); TIME_MEASURE_FINISH(time1); time_tx_exists += time1; + if (! m_batch_active) + txn.commit(); if (get_result == MDB_NOTFOUND) { - if (! m_batch_active) - txn.commit(); LOG_PRINT_L1("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db"); return false; } @@ -1576,9 +1620,10 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<crypto::hash> key(h); MDB_val result; @@ -1588,7 +1633,9 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR("DB error attempting to fetch tx unlock time from hash")); - return *(const uint64_t*)result.mv_data; + ret = *(const uint64_t*)result.mv_data; + txn.commit(); + return ret; } transaction BlockchainLMDB::get_tx(const crypto::hash& h) const @@ -1602,8 +1649,8 @@ transaction BlockchainLMDB::get_tx(const crypto::hash& h) const txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<crypto::hash> key(h); @@ -1632,8 +1679,8 @@ uint64_t BlockchainLMDB::get_tx_count() const check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_stat db_stats; if (mdb_stat(txn, m_txs, &db_stats)) @@ -1663,14 +1710,15 @@ uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<crypto::hash> key(h); @@ -1683,10 +1731,11 @@ uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR("DB error attempting to fetch tx height from hash")); + ret = *(const uint64_t*)result.mv_data; if (! m_batch_active) txn.commit(); - return *(const uint64_t*)result.mv_data; + return ret; } uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const @@ -1695,8 +1744,8 @@ uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); lmdb_cur cur(txn, m_output_amounts); @@ -1723,9 +1772,10 @@ output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + output_data_t ret; mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<uint64_t> k(global_index); MDB_val v; @@ -1734,8 +1784,9 @@ output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const throw1(OUTPUT_DNE("Attempting to get output pubkey by global index, but key does not exist")); else if (get_result) throw0(DB_ERROR("Error attempting to retrieve an output pubkey from the db")); + ret = *(output_data_t *) v.mv_data; txn.commit(); - return *(output_data_t *) v.mv_data; + return ret; } output_data_t BlockchainLMDB::get_output_key(const uint64_t& amount, const uint64_t& index) @@ -1752,14 +1803,15 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index_from_global(const uint64_t& LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + tx_out_index ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } MDB_val_copy<uint64_t> k(index); MDB_val v; @@ -1777,10 +1829,12 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index_from_global(const uint64_t& throw1(OUTPUT_DNE("output with given index not in db")); else if (get_result) throw0(DB_ERROR("DB error attempting to fetch output tx index")); + + ret = tx_out_index(tx_hash, *(const uint64_t *)v.mv_data); if (! m_batch_active) txn.commit(); - return tx_out_index(tx_hash, *(const uint64_t *)v.mv_data); + return ret; } tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) @@ -1803,8 +1857,8 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_output_indices(const crypto::hash& std::vector<uint64_t> index_vec; mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); lmdb_cur cur(txn, m_tx_outputs); @@ -1848,8 +1902,8 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_amount_output_indices(const crypto: transaction tx = get_tx(h); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); uint64_t i = 0; uint64_t global_index; @@ -1919,8 +1973,8 @@ bool BlockchainLMDB::has_key_image(const crypto::key_image& img) const check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val_copy<crypto::key_image> val_key(img); MDB_val unused; @@ -1940,8 +1994,8 @@ bool BlockchainLMDB::for_all_key_images(std::function<bool(const crypto::key_ima check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val k; MDB_val v; @@ -1976,8 +2030,8 @@ bool BlockchainLMDB::for_all_blocks(std::function<bool(uint64_t, const crypto::h check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val k; MDB_val v; @@ -2020,8 +2074,8 @@ bool BlockchainLMDB::for_all_transactions(std::function<bool(const crypto::hash& check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val k; MDB_val v; @@ -2061,8 +2115,8 @@ bool BlockchainLMDB::for_all_outputs(std::function<bool(uint64_t amount, const c check_open(); mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); MDB_val k; MDB_val v; @@ -2112,8 +2166,8 @@ void BlockchainLMDB::batch_start(uint64_t batch_num_blocks) m_write_batch_txn = new mdb_txn_safe(); // NOTE: need to make sure it's destroyed properly when done - if (mdb_txn_begin(m_env, NULL, 0, *m_write_batch_txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, *m_write_batch_txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); // indicates this transaction is for batch transactions, but not whether it's // active m_write_batch_txn->m_batch_txn = true; @@ -2210,8 +2264,8 @@ uint64_t BlockchainLMDB::add_block(const block& blk, const size_t& block_size, c mdb_txn_safe txn; if (! m_batch_active) { - if (mdb_txn_begin(m_env, NULL, 0, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); m_write_txn = &txn; } @@ -2248,8 +2302,8 @@ void BlockchainLMDB::pop_block(block& blk, std::vector<transaction>& txs) mdb_txn_safe txn; if (! m_batch_active) { - if (mdb_txn_begin(m_env, NULL, 0, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); m_write_txn = &txn; } @@ -2287,8 +2341,8 @@ void BlockchainLMDB::get_output_tx_and_index_from_global(const std::vector<uint6 txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } for (const uint64_t &index : global_indices) @@ -2339,8 +2393,8 @@ void BlockchainLMDB::get_output_global_indices(const uint64_t& amount, const std txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } lmdb_cur cur(*txn_ptr, m_output_amounts); @@ -2445,8 +2499,8 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); } for (const uint64_t &index : global_indices) { @@ -2500,8 +2554,8 @@ void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t hei txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, 0, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); txn_ptr = &txn; } @@ -2519,14 +2573,15 @@ uint64_t BlockchainLMDB::get_hard_fork_starting_height(uint8_t version) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint64_t ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); txn_ptr = &txn; } @@ -2538,9 +2593,10 @@ uint64_t BlockchainLMDB::get_hard_fork_starting_height(uint8_t version) const if (result) throw0(DB_ERROR("Error attempting to retrieve a hard fork starting height from the db")); + ret = *(const uint64_t*)val_ret.mv_data; if (!m_batch_active) txn.commit(); - return *(const uint64_t*)val_ret.mv_data; + return ret; } void BlockchainLMDB::set_hard_fork_version(uint64_t height, uint8_t version) @@ -2555,8 +2611,8 @@ void BlockchainLMDB::set_hard_fork_version(uint64_t height, uint8_t version) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, 0, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); txn_ptr = &txn; } @@ -2574,14 +2630,15 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); + uint8_t ret; mdb_txn_safe txn; mdb_txn_safe* txn_ptr = &txn; if (m_batch_active) txn_ptr = m_write_txn; else { - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); + if (auto mdb_res = mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str())); txn_ptr = &txn; } @@ -2591,9 +2648,10 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const if (result == MDB_NOTFOUND || result) throw0(DB_ERROR("Error attempting to retrieve a hard fork version from the db")); + ret = *(const uint8_t*)val_ret.mv_data; if (!m_batch_active) txn.commit(); - return *(const uint8_t*)val_ret.mv_data; + return ret; } void BlockchainLMDB::fixup() diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index 925b62a54..5e5a9ff44 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -91,4 +91,9 @@ namespace command_line , "Show time-stats when processing blocks/txs and disk synchronization." , 0 }; + const command_line::arg_descriptor<bool> arg_fakechain = { + "fakechain" + , "Use a fake chain for testing purposes." + , false + }; } diff --git a/src/common/command_line.h b/src/common/command_line.h index ffac71704..8955b826e 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -215,4 +215,5 @@ namespace command_line extern const arg_descriptor<uint64_t> arg_prep_blocks_threads; extern const arg_descriptor<uint64_t> arg_db_auto_remove_logs; extern const arg_descriptor<uint64_t> arg_show_time_stats; + extern const arg_descriptor<bool> arg_fakechain; } diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 2d71b61a1..5823c86f7 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -236,7 +236,7 @@ uint64_t Blockchain::get_current_blockchain_height() const //------------------------------------------------------------------ //FIXME: possibly move this into the constructor, to avoid accidentally // dereferencing a null BlockchainDB pointer -bool Blockchain::init(BlockchainDB* db, const bool testnet) +bool Blockchain::init(BlockchainDB* db, const bool testnet, const bool fakechain) { LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); @@ -293,8 +293,11 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet) { } - // ensure we fixup anything we found and fix in the future - m_db->fixup(); + if (!fakechain) + { + // ensure we fixup anything we found and fix in the future + m_db->fixup(); + } // check how far behind we are uint64_t top_block_timestamp = m_db->get_top_block_timestamp(); @@ -311,7 +314,7 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet) m_async_pool.create_thread(boost::bind(&boost::asio::io_service::run, &m_async_service)); #if defined(PER_BLOCK_CHECKPOINT) - if (m_fast_sync && get_blocks_dat_start(testnet) != nullptr) + if (!fakechain && m_fast_sync && get_blocks_dat_start(testnet) != nullptr) { if (get_blocks_dat_size(testnet) > 4) { @@ -1361,7 +1364,7 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<block if(start_offset > m_db->height()) return false; - for(size_t i = start_offset; i < start_offset + count && i <= m_db->height();i++) + for(size_t i = start_offset; i < start_offset + count && i < m_db->height();i++) { blocks.push_back(m_db->get_block_from_height(i)); } @@ -2631,7 +2634,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& // do this after updating the hard fork state since the size limit may change due to fork update_next_cumulative_size_limit(); - LOG_PRINT_L1("+++++ BLOCK SUCCESSFULLY ADDED" << std::endl << "id:\t" << id << std::endl << "PoW:\t" << proof_of_work << std::endl << "HEIGHT " << new_height << ", difficulty:\t" << current_diffic << std::endl << "block reward: " << print_money(fee_summary + base_reward) << "(" << print_money(base_reward) << " + " << print_money(fee_summary) << "), coinbase_blob_size: " << coinbase_blob_size << ", cumulative size: " << cumulative_block_size << ", " << block_processing_time << "(" << target_calculating_time << "/" << longhash_calculating_time << ")ms"); + LOG_PRINT_L1("+++++ BLOCK SUCCESSFULLY ADDED" << std::endl << "id:\t" << id << std::endl << "PoW:\t" << proof_of_work << std::endl << "HEIGHT " << new_height-1 << ", difficulty:\t" << current_diffic << std::endl << "block reward: " << print_money(fee_summary + base_reward) << "(" << print_money(base_reward) << " + " << print_money(fee_summary) << "), coinbase_blob_size: " << coinbase_blob_size << ", cumulative size: " << cumulative_block_size << ", " << block_processing_time << "(" << target_calculating_time << "/" << longhash_calculating_time << ")ms"); if(m_show_time_stats) { LOG_PRINT_L0("Height: " << new_height << " blob: " << coinbase_blob_size << " cumm: " diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index c83314634..f0b03ab0a 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -91,7 +91,7 @@ namespace cryptonote Blockchain(tx_memory_pool& tx_pool); - bool init(BlockchainDB* db, const bool testnet = false); + bool init(BlockchainDB* db, const bool testnet = false, const bool fakechain = false); bool deinit(); void set_checkpoints(checkpoints&& chk_pts) { m_checkpoints = chk_pts; } diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 2f21bd4f1..960c8eff8 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -97,7 +97,7 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::update_checkpoints() { - if (m_testnet) return true; + if (m_testnet || m_fakechain) return true; if (m_checkpoints_updating.test_and_set()) return true; @@ -145,18 +145,20 @@ namespace cryptonote command_line::add_arg(desc, command_line::arg_db_sync_mode); command_line::add_arg(desc, command_line::arg_show_time_stats); command_line::add_arg(desc, command_line::arg_db_auto_remove_logs); + command_line::add_arg(desc, command_line::arg_fakechain); } //----------------------------------------------------------------------------------------------- bool core::handle_command_line(const boost::program_options::variables_map& vm) { m_testnet = command_line::get_arg(vm, command_line::arg_testnet_on); + m_fakechain = command_line::get_arg(vm, command_line::arg_fakechain); auto data_dir_arg = m_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; m_config_folder = command_line::get_arg(vm, data_dir_arg); auto data_dir = boost::filesystem::path(m_config_folder); - if (!m_testnet) + if (!m_testnet && !m_fakechain) { cryptonote::checkpoints checkpoints; if (!cryptonote::create_checkpoints(checkpoints)) @@ -257,6 +259,9 @@ namespace cryptonote boost::filesystem::path folder(m_config_folder); + if (m_fakechain) + folder /= "fake"; + folder /= db->get_db_name(); LOG_PRINT_L0("Loading blockchain from folder " << folder.string() << " ..."); @@ -337,7 +342,7 @@ namespace cryptonote m_blockchain_storage.set_user_options(blocks_threads, blocks_per_sync, sync_mode, fast_sync); - r = m_blockchain_storage.init(db, m_testnet); + r = m_blockchain_storage.init(db, m_testnet, m_fakechain); bool show_time_stats = command_line::get_arg(vm, command_line::arg_show_time_stats) != 0; m_blockchain_storage.set_show_time_stats(show_time_stats); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index e7a6c4154..5d665cb98 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -199,6 +199,7 @@ namespace cryptonote uint64_t m_target_blockchain_height; bool m_testnet; + bool m_fakechain; std::string m_checkpoints_path; time_t m_last_dns_checkpoints_update; time_t m_last_json_checkpoints_update; diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index defbeb3b3..e2dcd35f5 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -113,7 +113,7 @@ namespace cryptonote needed_fee *= FEE_PER_KB; if (!kept_by_block && fee < needed_fee /*&& fee < MINING_ALLOWED_LEGACY_FEE*/) { - LOG_PRINT_L1("transaction fee is not enough: " << print_money(fee) << ", minumim fee: " << print_money(needed_fee)); + LOG_PRINT_L1("transaction fee is not enough: " << print_money(fee) << ", minimum fee: " << print_money(needed_fee)); tvc.m_verifivation_failed = true; return false; } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 23095d37d..d1ff09170 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -80,18 +80,18 @@ namespace { const command_line::arg_descriptor<std::string> arg_wallet_file = {"wallet-file", sw::tr("Use wallet <arg>"), ""}; const command_line::arg_descriptor<std::string> arg_generate_new_wallet = {"generate-new-wallet", sw::tr("Generate new wallet and save it to <arg> or <address>.wallet by default"), ""}; - const command_line::arg_descriptor<std::string> arg_generate_from_view_key = {"generate-from-view-key", sw::tr("Generate wallet from (address:viewkey:filename) and save it to <filename>"), ""}; + const command_line::arg_descriptor<std::string> arg_generate_from_view_key = {"generate-from-view-key", sw::tr("Generate incoming-only wallet from (address:viewkey:filename) and save it to <filename>"), ""}; const command_line::arg_descriptor<std::string> arg_daemon_address = {"daemon-address", sw::tr("Use daemon instance at <host>:<port>"), ""}; const command_line::arg_descriptor<std::string> arg_daemon_host = {"daemon-host", sw::tr("Use daemon instance at host <arg> instead of localhost"), ""}; const command_line::arg_descriptor<std::string> arg_password = {"password", sw::tr("Wallet password"), "", true}; - const command_line::arg_descriptor<std::string> arg_electrum_seed = {"electrum-seed", sw::tr("Specify electrum seed for wallet recovery/creation"), ""}; - const command_line::arg_descriptor<bool> arg_restore_deterministic_wallet = {"restore-deterministic-wallet", sw::tr("Recover wallet using electrum-style mnemonic"), false}; - const command_line::arg_descriptor<bool> arg_non_deterministic = {"non-deterministic", sw::tr("creates non-deterministic view and spend keys"), false}; - const command_line::arg_descriptor<int> arg_daemon_port = {"daemon-port", sw::tr("Use daemon instance at port <arg> instead of 8081"), 0}; + const command_line::arg_descriptor<std::string> arg_electrum_seed = {"electrum-seed", sw::tr("Specify Electrum seed for wallet recovery/creation"), ""}; + const command_line::arg_descriptor<bool> arg_restore_deterministic_wallet = {"restore-deterministic-wallet", sw::tr("Recover wallet using Electrum-style mnemonic seed"), false}; + const command_line::arg_descriptor<bool> arg_non_deterministic = {"non-deterministic", sw::tr("Create non-deterministic view and spend keys"), false}; + const command_line::arg_descriptor<int> arg_daemon_port = {"daemon-port", sw::tr("Use daemon instance at port <arg> instead of 18081"), 0}; const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", LOG_LEVEL_0}; const command_line::arg_descriptor<std::string> arg_log_file = {"log-file", sw::tr("Specify log file"), ""}; - const command_line::arg_descriptor<bool> arg_testnet = {"testnet", sw::tr("Used to deploy test nets. The daemon must be launched with --testnet flag"), false}; - const command_line::arg_descriptor<bool> arg_restricted = {"restricted-rpc", sw::tr("Restricts RPC to view only commands"), false}; + const command_line::arg_descriptor<bool> arg_testnet = {"testnet", sw::tr("For testnet. Daemon must also be launched with --testnet flag"), false}; + const command_line::arg_descriptor<bool> arg_restricted = {"restricted-rpc", sw::tr("Restricts RPC to view-only commands"), false}; const command_line::arg_descriptor<bool> arg_trusted_daemon = {"trusted-daemon", sw::tr("Enable commands which rely on a trusted daemon"), false}; const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""}; @@ -103,7 +103,7 @@ namespace { if (status == CORE_RPC_STATUS_BUSY) { - err = sw::tr("daemon is busy. Please try later"); + err = sw::tr("daemon is busy. Please try again later."); } else if (status != CORE_RPC_STATUS_OK) { @@ -112,7 +112,7 @@ namespace } else { - err = sw::tr("possible lost connection to daemon"); + err = sw::tr("possibly lost connection to daemon"); } return err; } @@ -246,7 +246,7 @@ bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<st if (m_wallet->watch_only()) { - fail_msg_writer() << tr("This wallet is watch-only and cannot have a seed."); + fail_msg_writer() << tr("wallet is watch-only and has no seed"); return true; } if (m_wallet->is_deterministic()) @@ -266,7 +266,7 @@ bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<st } else { - fail_msg_writer() << tr("The wallet is non-deterministic. Cannot display seed."); + fail_msg_writer() << tr("wallet is non-deterministic and has no seed"); } return true; } @@ -276,12 +276,12 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s bool success = false; if (m_wallet->watch_only()) { - fail_msg_writer() << tr("This wallet is watch-only and doesn't have a seed."); + fail_msg_writer() << tr("wallet is watch-only and has no seed"); return true; } if (!m_wallet->is_deterministic()) { - fail_msg_writer() << tr("This wallet is non-deterministic and doesn't have a seed."); + fail_msg_writer() << tr("wallet is non-deterministic and has no seed"); return true; } tools::password_container pwd_container; @@ -311,7 +311,7 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string> bool success = false; if (m_wallet->watch_only()) { - fail_msg_writer() << tr("This wallet is watch-only and cannot transfer."); + fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); return true; } tools::password_container pwd_container; @@ -340,7 +340,7 @@ bool simple_wallet::set_store_tx_info(const std::vector<std::string> &args/* = s bool success = false; if (m_wallet->watch_only()) { - fail_msg_writer() << tr("This wallet is watch-only and cannot transfer."); + fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); return true; } tools::password_container pwd_container; @@ -369,20 +369,20 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s bool success = false; if (m_wallet->watch_only()) { - fail_msg_writer() << tr("This wallet is watch-only and cannot transfer."); + fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); return true; } try { if (strchr(args[1].c_str(), '-')) { - fail_msg_writer() << tr("Error: mixin must be an integer greater or equal to 2"); + fail_msg_writer() << tr("mixin must be an integer >= 2"); return true; } uint32_t mixin = boost::lexical_cast<uint32_t>(args[1]); if (mixin < 2 && mixin != 0) { - fail_msg_writer() << tr("Error: mixin must be an integer greater or equal to 2"); + fail_msg_writer() << tr("mixin must be an integer >= 2"); return true; } if (mixin == 0) @@ -410,12 +410,12 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s } catch(const boost::bad_lexical_cast &) { - fail_msg_writer() << tr("Error: mixin must be an integer greater or equal to 2"); + fail_msg_writer() << tr("mixin must be an integer >= 2"); return true; } catch(...) { - fail_msg_writer() << tr("Error changing default mixin"); + fail_msg_writer() << tr("could not change default mixin"); return true; } } @@ -478,7 +478,7 @@ static bool parse_refresh_type(const std::string &s, tools::wallet2::RefreshType return true; } } - fail_msg_writer() << tr("Failed to parse refresh type"); + fail_msg_writer() << tr("failed to parse refresh type"); return false; } @@ -530,27 +530,27 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("start_mining", boost::bind(&simple_wallet::start_mining, this, _1), tr("start_mining [<number_of_threads>] - Start mining in daemon")); m_cmd_binder.set_handler("stop_mining", boost::bind(&simple_wallet::stop_mining, this, _1), tr("Stop mining in daemon")); m_cmd_binder.set_handler("save_bc", boost::bind(&simple_wallet::save_bc, this, _1), tr("Save current blockchain data")); - m_cmd_binder.set_handler("refresh", boost::bind(&simple_wallet::refresh, this, _1), tr("Resynchronize transactions and balance")); + m_cmd_binder.set_handler("refresh", boost::bind(&simple_wallet::refresh, this, _1), tr("Synchronize transactions and balance")); m_cmd_binder.set_handler("balance", boost::bind(&simple_wallet::show_balance, this, _1), tr("Show current wallet balance")); - m_cmd_binder.set_handler("incoming_transfers", boost::bind(&simple_wallet::show_incoming_transfers, this, _1), tr("incoming_transfers [available|unavailable] - Show incoming transfers - all of them or filter them by availability")); - m_cmd_binder.set_handler("payments", boost::bind(&simple_wallet::show_payments, this, _1), tr("payments <payment_id_1> [<payment_id_2> ... <payment_id_N>] - Show payments <payment_id_1>, ... <payment_id_N>")); + m_cmd_binder.set_handler("incoming_transfers", boost::bind(&simple_wallet::show_incoming_transfers, this, _1), tr("incoming_transfers [available|unavailable] - Show incoming transfers, all or filtered by availability")); + m_cmd_binder.set_handler("payments", boost::bind(&simple_wallet::show_payments, this, _1), tr("payments <PID_1> [<PID_2> ... <PID_N>] - Show payments for given payment ID[s]")); m_cmd_binder.set_handler("bc_height", boost::bind(&simple_wallet::show_blockchain_height, this, _1), tr("Show blockchain height")); - m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer, this, _1), tr("transfer [<mixin_count>] <addr_1> <amount_1> [<addr_2> <amount_2> ... <addr_N> <amount_N>] [payment_id] - Transfer <amount_1>,... <amount_N> to <address_1>,... <address_N>, respectively. <mixin_count> is the number of transactions yours is indistinguishable from (from 0 to maximum available)")); + m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer, this, _1), tr("transfer [<mixin_count>] <addr_1> <amount_1> [<addr_2> <amount_2> ... <addr_N> <amount_N>] [payment_id] - Transfer <amount_1>,... <amount_N> to <address_1>,... <address_N>, respectively. <mixin_count> is the number of extra inputs to include for untraceability (from 0 to maximum available)")); m_cmd_binder.set_handler("transfer_new", boost::bind(&simple_wallet::transfer_new, this, _1), tr("Same as transfer, but using a new transaction building algorithm")); - m_cmd_binder.set_handler("sweep_dust", boost::bind(&simple_wallet::sweep_dust, this, _1), tr("Send all dust outputs to the same address with mixin 0")); - m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level> - Change current log detalization level, <level> is a number 0-4")); + m_cmd_binder.set_handler("sweep_dust", boost::bind(&simple_wallet::sweep_dust, this, _1), tr("Send all dust outputs to yourself with mixin 0")); + m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level> - Change current log detail level, <0-4>")); m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), tr("Show current wallet public address")); - m_cmd_binder.set_handler("integrated_address", boost::bind(&simple_wallet::print_integrated_address, this, _1), tr("Convert a payment ID to an integrated address for the current wallet public address (no arguments use a random payment ID), or display standard addres and payment ID corresponding to an integrated addres")); - m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), tr("Save wallet synchronized data")); - m_cmd_binder.set_handler("save_watch_only", boost::bind(&simple_wallet::save_watch_only, this, _1), tr("Save watch only keys file")); - m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Get viewkey")); - m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Get spendkey")); - m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Get deterministic seed")); - m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("available options: seed language - Set wallet seed langage; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store per outgoing tx info (destination address, payment id, tx secret key) for future reference; default_mixin <n> - set default mixin (default default is 4; auto-refresh <1|0> - whether to automatically refresh new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - control the wallet refresh speedup/assumptions balance")); + m_cmd_binder.set_handler("integrated_address", boost::bind(&simple_wallet::print_integrated_address, this, _1), tr("integrated_address [PID] - Encode a payment ID into an integrated address for the current wallet public address (no argument uses a random payment ID), or decode an integrated address to standard address and payment ID")); + m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), tr("Save wallet data")); + m_cmd_binder.set_handler("save_watch_only", boost::bind(&simple_wallet::save_watch_only, this, _1), tr("Save a watch-only keys file")); + m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key")); + m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key")); + m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed")); + m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour")); m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs")); - m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given tx")); - m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to a given address in a partcular tx")); - m_cmd_binder.set_handler("show_transfers", boost::bind(&simple_wallet::show_transfers, this, _1), tr("show_transfers [in|out] [<min_height> [<max_height>]] - show incoming/outgoing transfers within an optional height range")); + m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>")); + m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>")); + m_cmd_binder.set_handler("show_transfers", boost::bind(&simple_wallet::show_transfers, this, _1), tr("show_transfers [in|out] [<min_height> [<max_height>]] - Show incoming/outgoing transfers within an optional height range")); m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help")); } //---------------------------------------------------------------------------------------------------- @@ -612,7 +612,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args) { if (args.size() <= 1) { - fail_msg_writer() << tr("set default-mixin: needs an argument (integer greater of equal to 2)"); + fail_msg_writer() << tr("set default-mixin: needs an argument (integer >= 2)"); return true; } else @@ -643,7 +643,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args) if (args.size() <= 1) { fail_msg_writer() << tr("set refresh-type: needs an argument:") << - tr("full (slowest, no assumptions), optimize-coinbase (fast, assumes the whole coinbase is paid to a single address), no-coinbase (fastest, assumes we receive no coinbase transaction), default (same as optimize-coinbase)"); + tr("full (slowest, no assumptions); optimize-coinbase (fast, assumes the whole coinbase is paid to a single address); no-coinbase (fastest, assumes we receive no coinbase transaction), default (same as optimize-coinbase)"); return true; } else @@ -664,7 +664,7 @@ bool simple_wallet::set_log(const std::vector<std::string> &args) { if(args.size() != 1) { - fail_msg_writer() << tr("use: set_log <log_level_number_0-4>"); + fail_msg_writer() << tr("usage: set_log <log_level_number_0-4>"); return true; } uint16_t l = 0; @@ -690,7 +690,7 @@ bool simple_wallet::ask_wallet_create_if_needed() bool valid_path = false; do { wallet_path = command_line::input_line( - tr("Specify wallet file name (e.g., wallet.bin). If the wallet doesn't exist, it will be created.\n" + tr("Specify wallet file name (e.g., MyWallet). If the wallet doesn't exist, it will be created.\n" "Wallet file name: ") ); valid_path = tools::wallet2::wallet_valid_path_format(wallet_path); @@ -715,7 +715,7 @@ bool simple_wallet::ask_wallet_create_if_needed() { if (!m_generate_new.empty() || m_restore_deterministic_wallet || !m_generate_from_view_key.empty()) { - fail_msg_writer() << tr("Attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting."); + fail_msg_writer() << tr("attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting."); return false; } } @@ -734,7 +734,7 @@ bool simple_wallet::ask_wallet_create_if_needed() r = true; }else { - fail_msg_writer() << tr("Keys file wasn't found: failed to open wallet: ") << "\"" << wallet_path << "\"."; + fail_msg_writer() << tr("keys file not found: failed to open wallet: ") << "\"" << wallet_path << "\"."; r = false; } } @@ -765,13 +765,13 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) if (!m_daemon_address.empty() && !m_daemon_host.empty() && 0 != m_daemon_port) { - fail_msg_writer() << tr("you can't specify daemon host or port several times"); + fail_msg_writer() << tr("can't specify daemon host or port more than once"); return false; } if((!m_generate_new.empty()) + (!m_wallet_file.empty()) + (!m_generate_from_view_key.empty()) > 1) { - fail_msg_writer() << tr("Specifying more than one of --generate-new-wallet=\"wallet_name\", --wallet-file=\"wallet_name\" and --generate-from-keys doesn't make sense!"); + fail_msg_writer() << tr("can't specify more than one of --generate-new-wallet=\"wallet_name\", --wallet-file=\"wallet_name\" and --generate-from-view-key"); return false; } else if (m_generate_new.empty() && m_wallet_file.empty() && m_generate_from_view_key.empty()) @@ -817,13 +817,13 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) { if (m_non_deterministic) { - fail_msg_writer() << tr("Cannot specify both --restore-deterministic-wallet and --non-deterministic"); + fail_msg_writer() << tr("can't specify both --restore-deterministic-wallet and --non-deterministic"); return false; } if (m_electrum_seed.empty()) { - m_electrum_seed = command_line::input_line("Specify electrum seed: "); + m_electrum_seed = command_line::input_line("Specify Electrum seed: "); if (m_electrum_seed.empty()) { fail_msg_writer() << tr("specify a recovery parameter with the --electrum-seed=\"words list here\""); @@ -833,7 +833,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) if (!crypto::ElectrumWords::words_to_bytes(m_electrum_seed, m_recovery_key, old_language)) { - fail_msg_writer() << tr("electrum-style word list failed verification"); + fail_msg_writer() << tr("Electrum-style word list failed verification"); return false; } } @@ -854,7 +854,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) crypto::hash8 new_payment_id; if(!get_account_integrated_address_from_str(address, has_payment_id, new_payment_id, testnet, parts[0])) { - fail_msg_writer() << tr("Failed to parse address"); + fail_msg_writer() << tr("failed to parse address"); return false; } @@ -862,7 +862,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) cryptonote::blobdata viewkey_data; if(!epee::string_tools::parse_hexstr_to_binbuff(parts[1], viewkey_data)) { - fail_msg_writer() << tr("Failed to parse view key secret key"); + fail_msg_writer() << tr("failed to parse view key secret key"); return false; } crypto::secret_key viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data()); @@ -885,7 +885,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) else { bool r = open_wallet(m_wallet_file, pwd_container.password(), testnet); - CHECK_AND_ASSERT_MES(r, false, tr("could not open account")); + CHECK_AND_ASSERT_MES(r, false, tr("failed to open account")); } return true; @@ -920,8 +920,8 @@ bool simple_wallet::try_connect_to_daemon() if (!m_wallet->check_connection()) { fail_msg_writer() << tr("wallet failed to connect to daemon: ") << m_daemon_address << ". " << - tr("Daemon either is not started or passed wrong port. " - "Please, make sure that daemon is running or restart the wallet with correct daemon address."); + tr("Daemon either is not started or wrong port was passed. " + "Please make sure daemon is running or restart the wallet with the correct daemon address."); return false; } return true; @@ -956,12 +956,12 @@ std::string simple_wallet::get_mnemonic_language() if (!((language_number >= 0) && (static_cast<unsigned int>(language_number) < language_list.size()))) { language_number = -1; - fail_msg_writer() << tr("Invalid language choice passed. Please try again.\n"); + fail_msg_writer() << tr("invalid language choice passed. Please try again.\n"); } } catch (std::exception &e) { - fail_msg_writer() << tr("Invalid language choice passed. Please try again.\n"); + fail_msg_writer() << tr("invalid language choice passed. Please try again.\n"); } } return language_list[language_number]; @@ -1003,7 +1003,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string recovery_val = m_wallet->generate(wallet_file, password, recovery_key, recover, two_random); message_writer(epee::log_space::console_color_white, true) << tr("Generated new wallet: ") << m_wallet->get_account().get_public_address_str(m_wallet->testnet()); - std::cout << tr("view key: ") << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << ENDL; + std::cout << tr("View key: ") << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << ENDL; } catch (const std::exception& e) { @@ -1020,12 +1020,12 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string success_msg_writer() << "**********************************************************************\n" << - tr("Your wallet has been generated.\n" - "To start synchronizing with the daemon use \"refresh\" command.\n" + tr("Your wallet has been generated!\n" + "To start synchronizing with the daemon, use \"refresh\" command.\n" "Use \"help\" command to see the list of available commands.\n" - "Always use \"exit\" command when closing simplewallet to save\n" - "current session's state. Otherwise, you will possibly need to synchronize \n" - "your wallet again. Your wallet key is NOT under risk anyway.\n") + "Always use \"exit\" command when closing simplewallet to save your\n" + "current session's state. Otherwise, you might need to synchronize \n" + "your wallet again (your wallet keys are NOT at risk in any case).\n") ; if (!two_random) @@ -1051,7 +1051,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string m_wallet->generate(wallet_file, password, address, viewkey); message_writer(epee::log_space::console_color_white, true) << tr("Generated new watch-only wallet: ") << m_wallet->get_account().get_public_address_str(m_wallet->testnet()); - std::cout << tr("view key: ") << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << ENDL; + std::cout << tr("View key: ") << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << ENDL; } catch (const std::exception& e) { @@ -1140,7 +1140,7 @@ bool simple_wallet::close_wallet() bool r = m_wallet->deinit(); if (!r) { - fail_msg_writer() << tr("failed to deinit wallet"); + fail_msg_writer() << tr("failed to deinitialize wallet"); return false; } @@ -1205,7 +1205,7 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args) { if (!m_trusted_daemon) { - fail_msg_writer() << tr("This command assume a trusted daemon. Enable with --trusted-daemon"); + fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon"); return true; } @@ -1278,7 +1278,7 @@ bool simple_wallet::save_bc(const std::vector<std::string>& args) if (err.empty()) success_msg_writer() << tr("Blockchain saved"); else - fail_msg_writer() << tr("Blockchain can't be saved: ") << err; + fail_msg_writer() << tr("blockchain can't be saved: ") << err; return true; } //---------------------------------------------------------------------------------------------------- @@ -1366,21 +1366,21 @@ bool simple_wallet::refresh(const std::vector<std::string>& args) } catch (const tools::error::daemon_busy&) { - ss << tr("daemon is busy. Please try later"); + ss << tr("daemon is busy. Please try again later."); } catch (const tools::error::no_connection_to_daemon&) { - ss << tr("no connection to daemon. Please, make sure daemon is running"); + ss << tr("no connection to daemon. Please make sure daemon is running."); } catch (const tools::error::wallet_rpc_error& e) { - LOG_ERROR("Unknown RPC error: " << e.to_string()); + LOG_ERROR("RPC error: " << e.to_string()); ss << tr("RPC error: ") << e.what(); } catch (const tools::error::refresh_error& e) { LOG_ERROR("refresh error: " << e.to_string()); - ss << tr("Error refreshing: ") << e.what(); + ss << tr("refresh error: ") << e.what(); } catch (const tools::error::wallet_internal_error& e) { @@ -1394,7 +1394,7 @@ bool simple_wallet::refresh(const std::vector<std::string>& args) } catch (...) { - LOG_ERROR("Unknown error"); + LOG_ERROR("unknown error"); ss << tr("unknown error"); } @@ -1410,7 +1410,7 @@ bool simple_wallet::refresh(const std::vector<std::string>& args) //---------------------------------------------------------------------------------------------------- bool simple_wallet::show_balance(const std::vector<std::string>& args/* = std::vector<std::string>()*/) { - success_msg_writer() << tr("balance: ") << print_money(m_wallet->balance()) << ", " + success_msg_writer() << tr("Balance: ") << print_money(m_wallet->balance()) << ", " << tr("unlocked balance: ") << print_money(m_wallet->unlocked_balance()) << ", " << tr("including unlocked dust: ") << print_money(m_wallet->unlocked_dust_balance(tools::tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD))); return true; @@ -1517,7 +1517,7 @@ bool simple_wallet::show_payments(const std::vector<std::string> &args) } else { - fail_msg_writer() << tr("payment id has invalid format, expected 64-character string: ") << arg; + fail_msg_writer() << tr("payment ID has invalid format, expected 16 or 64 character hex string: ") << arg; } } @@ -1551,7 +1551,7 @@ bool simple_wallet::rescan_spent(const std::vector<std::string> &args) { if (!m_trusted_daemon) { - fail_msg_writer() << tr("This command assume a trusted daemon. Enable with --trusted-daemon"); + fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon"); return true; } @@ -1564,11 +1564,11 @@ bool simple_wallet::rescan_spent(const std::vector<std::string> &args) } catch (const tools::error::daemon_busy&) { - fail_msg_writer() << tr("daemon is busy. Please try later"); + fail_msg_writer() << tr("daemon is busy. Please try again later."); } catch (const tools::error::no_connection_to_daemon&) { - fail_msg_writer() << tr("no connection to daemon. Please, make sure daemon is running."); + fail_msg_writer() << tr("no connection to daemon. Please make sure daemon is running."); } catch (const tools::error::is_key_image_spent_error&) { @@ -1576,7 +1576,7 @@ bool simple_wallet::rescan_spent(const std::vector<std::string> &args) } catch (const tools::error::wallet_rpc_error& e) { - LOG_ERROR("Unknown RPC error: " << e.to_string()); + LOG_ERROR("RPC error: " << e.to_string()); fail_msg_writer() << tr("RPC error: ") << e.what(); } catch (const std::exception& e) @@ -1586,7 +1586,7 @@ bool simple_wallet::rescan_spent(const std::vector<std::string> &args) } catch (...) { - LOG_ERROR("Unknown error"); + LOG_ERROR("unknown error"); fail_msg_writer() << tr("unknown error"); } @@ -1622,7 +1622,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str if(m_wallet->watch_only()) { - fail_msg_writer() << tr("This is a watch only wallet"); + fail_msg_writer() << tr("this is a watch only wallet"); return true; } @@ -1655,7 +1655,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str if(!r) { - fail_msg_writer() << tr("payment id has invalid format, expected 16 or 64 character string: ") << payment_id_str; + fail_msg_writer() << tr("payment id has invalid format, expected 16 or 64 character hex string: ") << payment_id_str; return true; } payment_id_seen = true; @@ -1706,23 +1706,23 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str if (confirm_dns_ok != "Y" && confirm_dns_ok != "y" && confirm_dns_ok != "Yes" && confirm_dns_ok != "yes" && confirm_dns_ok != tr("yes") && confirm_dns_ok != tr("no")) { - fail_msg_writer() << tr("You have cancelled the transfer request"); + fail_msg_writer() << tr("you have cancelled the transfer request"); return true; } } else { - fail_msg_writer() << tr("Failed to get a Monero address from: ") << local_args[i]; + fail_msg_writer() << tr("failed to get a Monero address from: ") << local_args[i]; return true; } } else if (addresses_from_dns.size() > 1) { - fail_msg_writer() << tr("Not yet supported: Multiple Monero addresses found for given URL: ") << url; + fail_msg_writer() << tr("not yet supported: Multiple Monero addresses found for given URL: ") << url; } else { - fail_msg_writer() << tr("Wrong address: ") << local_args[i]; + fail_msg_writer() << tr("wrong address: ") << local_args[i]; return true; } } @@ -1731,7 +1731,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str { if (payment_id_seen) { - fail_msg_writer() << tr("A single transaction cannot use more than one payment id: ") << local_args[i]; + fail_msg_writer() << tr("a single transaction cannot use more than one payment id: ") << local_args[i]; return true; } @@ -1740,7 +1740,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str bool r = add_extra_nonce_to_tx_extra(extra, extra_nonce); if(!r) { - fail_msg_writer() << tr("Failed to set up payment id, though it was decoded correctly"); + fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly"); return true; } } @@ -1780,7 +1780,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str std::string accepted = command_line::input_line(prompt_str); if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes") { - fail_msg_writer() << tr("Transaction cancelled."); + fail_msg_writer() << tr("transaction cancelled."); // would like to return false, because no tx made, but everything else returns true // and I don't know what returning false might adversely affect. *sigh* @@ -1801,15 +1801,15 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str } catch (const tools::error::daemon_busy&) { - fail_msg_writer() << tr("daemon is busy. Please try later"); + fail_msg_writer() << tr("daemon is busy. Please try again later."); } catch (const tools::error::no_connection_to_daemon&) { - fail_msg_writer() << tr("no connection to daemon. Please, make sure daemon is running."); + fail_msg_writer() << tr("no connection to daemon. Please make sure daemon is running."); } catch (const tools::error::wallet_rpc_error& e) { - LOG_ERROR("Unknown RPC error: " << e.to_string()); + LOG_ERROR("RPC error: " << e.to_string()); fail_msg_writer() << tr("RPC error: ") << e.what(); } catch (const tools::error::get_random_outs_error&) @@ -1851,7 +1851,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str } catch (const tools::error::tx_too_big& e) { - fail_msg_writer() << tr("Failed to find a suitable way to split transactions"); + fail_msg_writer() << tr("failed to find a suitable way to split transactions"); } catch (const tools::error::transfer_error& e) { @@ -1870,7 +1870,7 @@ bool simple_wallet::transfer_main(bool new_algorithm, const std::vector<std::str } catch (...) { - LOG_ERROR("Unknown error"); + LOG_ERROR("unknown error"); fail_msg_writer() << tr("unknown error"); } @@ -1895,7 +1895,7 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_) if(m_wallet->watch_only()) { - fail_msg_writer() << tr("This is a watch only wallet"); + fail_msg_writer() << tr("this is a watch only wallet"); return true; } @@ -1928,7 +1928,7 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_) std::string accepted = command_line::input_line(prompt_str); if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes") { - fail_msg_writer() << tr("Transaction cancelled."); + fail_msg_writer() << tr("transaction cancelled."); // would like to return false, because no tx made, but everything else returns true // and I don't know what returning false might adversely affect. *sigh* @@ -1948,15 +1948,15 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_) } catch (const tools::error::daemon_busy&) { - fail_msg_writer() << tr("daemon is busy. Please try later"); + fail_msg_writer() << tr("daemon is busy. Please try again later."); } catch (const tools::error::no_connection_to_daemon&) { - fail_msg_writer() << tr("no connection to daemon. Please, make sure daemon is running."); + fail_msg_writer() << tr("no connection to daemon. Please make sure daemon is running."); } catch (const tools::error::wallet_rpc_error& e) { - LOG_ERROR("Unknown RPC error: " << e.to_string()); + LOG_ERROR("RPC error: " << e.to_string()); fail_msg_writer() << tr("RPC error: ") << e.what(); } catch (const tools::error::get_random_outs_error&) @@ -1998,7 +1998,7 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_) } catch (const tools::error::tx_too_big& e) { - fail_msg_writer() << tr("Failed to find a suitable way to split transactions"); + fail_msg_writer() << tr("failed to find a suitable way to split transactions"); } catch (const tools::error::transfer_error& e) { @@ -2017,7 +2017,7 @@ bool simple_wallet::sweep_dust(const std::vector<std::string> &args_) } catch (...) { - LOG_ERROR("Unknown error"); + LOG_ERROR("unknown error"); fail_msg_writer() << tr("unknown error"); } @@ -2029,14 +2029,14 @@ bool simple_wallet::get_tx_key(const std::vector<std::string> &args_) std::vector<std::string> local_args = args_; if(local_args.size() != 1) { - fail_msg_writer() << tr("Usage: get_tx_key <txid>"); + fail_msg_writer() << tr("usage: get_tx_key <txid>"); return true; } cryptonote::blobdata txid_data; if(!epee::string_tools::parse_hexstr_to_binbuff(local_args.front(), txid_data)) { - fail_msg_writer() << tr("Failed to parse txid"); + fail_msg_writer() << tr("failed to parse txid"); return false; } crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); @@ -2045,12 +2045,12 @@ bool simple_wallet::get_tx_key(const std::vector<std::string> &args_) bool r = m_wallet->get_tx_key(txid, tx_key); if (r) { - success_msg_writer() << tr("tx key: ") << tx_key; + success_msg_writer() << tr("Tx key: ") << tx_key; return true; } else { - fail_msg_writer() << tr("No tx key found for this txid"); + fail_msg_writer() << tr("no tx key found for this txid"); return true; } } @@ -2060,7 +2060,7 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) std::vector<std::string> local_args = args_; if(local_args.size() != 3) { - fail_msg_writer() << tr("Usage: check_tx_key <txid> <txkey> <address>"); + fail_msg_writer() << tr("usage: check_tx_key <txid> <txkey> <address>"); return true; } @@ -2070,7 +2070,7 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) cryptonote::blobdata txid_data; if(!epee::string_tools::parse_hexstr_to_binbuff(local_args[0], txid_data)) { - fail_msg_writer() << tr("Failed to parse txid"); + fail_msg_writer() << tr("failed to parse txid"); return true; } crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); @@ -2078,7 +2078,7 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) cryptonote::blobdata tx_key_data; if(!epee::string_tools::parse_hexstr_to_binbuff(local_args[1], tx_key_data)) { - fail_msg_writer() << tr("Failed to parse tx key"); + fail_msg_writer() << tr("failed to parse tx key"); return true; } crypto::secret_key tx_key = *reinterpret_cast<const crypto::secret_key*>(tx_key_data.data()); @@ -2088,7 +2088,7 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) crypto::hash8 payment_id; if(!get_account_integrated_address_from_str(address, has_payment_id, payment_id, m_wallet->testnet(), local_args[2])) { - fail_msg_writer() << tr("Failed to parse address"); + fail_msg_writer() << tr("failed to parse address"); return true; } @@ -2098,32 +2098,32 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) if (!net_utils::invoke_http_json_remote_command2(m_daemon_address + "/gettransactions", req, res, m_http_client) || res.txs_as_hex.empty()) { - fail_msg_writer() << tr("Failed to get transaction from daemon"); + fail_msg_writer() << tr("failed to get transaction from daemon"); return true; } cryptonote::blobdata tx_data; if (!string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), tx_data)) { - fail_msg_writer() << tr("Failed to parse transaction from daemon"); + fail_msg_writer() << tr("failed to parse transaction from daemon"); return true; } crypto::hash tx_hash, tx_prefix_hash; cryptonote::transaction tx; if (!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash)) { - fail_msg_writer() << tr("Failed to validate transaction from daemon"); + fail_msg_writer() << tr("failed to validate transaction from daemon"); return true; } if (tx_hash != txid) { - fail_msg_writer() << tr("Failed to get the right transaction from daemon"); + fail_msg_writer() << tr("failed to get the right transaction from daemon"); return true; } crypto::key_derivation derivation; if (!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation)) { - fail_msg_writer() << tr("Failed to generate key derivation from supplied parameters"); + fail_msg_writer() << tr("failed to generate key derivation from supplied parameters"); return true; } @@ -2142,7 +2142,7 @@ bool simple_wallet::check_tx_key(const std::vector<std::string> &args_) } catch(...) { - LOG_ERROR("Unknown error"); + LOG_ERROR("unknown error"); fail_msg_writer() << tr("unknown error"); return true; } @@ -2169,7 +2169,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_) uint64_t max_height = (uint64_t)-1; if(local_args.size() > 3) { - fail_msg_writer() << tr("Usage: show_transfers [in|out|all|pending] [<min_height> [<max_height>]]"); + fail_msg_writer() << tr("usage: show_transfers [in|out|all|pending] [<min_height> [<max_height>]]"); return true; } @@ -2198,7 +2198,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_) min_height = boost::lexical_cast<uint64_t>(local_args[0]); } catch (boost::bad_lexical_cast &) { - fail_msg_writer() << tr("Bad min_height parameter:") << " " << local_args[0]; + fail_msg_writer() << tr("bad min_height parameter:") << " " << local_args[0]; return true; } local_args.erase(local_args.begin()); @@ -2210,7 +2210,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_) max_height = boost::lexical_cast<uint64_t>(local_args[0]); } catch (boost::bad_lexical_cast &) { - fail_msg_writer() << tr("Bad max_height parameter:") << " " << local_args[0]; + fail_msg_writer() << tr("bad max_height parameter:") << " " << local_args[0]; return true; } local_args.erase(local_args.begin()); @@ -2329,7 +2329,7 @@ bool simple_wallet::print_integrated_address(const std::vector<std::string> &arg crypto::hash8 payment_id; if (args.size() > 1) { - fail_msg_writer() << tr("integrated_address only takes one or zero arguments"); + fail_msg_writer() << tr("usage: integrated_address [payment ID]"); return true; } if (args.size() == 0) @@ -2352,17 +2352,17 @@ bool simple_wallet::print_integrated_address(const std::vector<std::string> &arg { if (has_payment_id) { - success_msg_writer() << boost::format(tr("Integrated address: account %s, payment id %s")) % + success_msg_writer() << boost::format(tr("Integrated address: account %s, payment ID %s")) % get_account_address_as_str(m_wallet->testnet(),addr) % epee::string_tools::pod_to_hex(payment_id); } else { - success_msg_writer() << tr("Standard address: account: ") << get_account_address_as_str(m_wallet->testnet(),addr); + success_msg_writer() << tr("Standard address: ") << get_account_address_as_str(m_wallet->testnet(),addr); } return true; } } - fail_msg_writer() << tr("Failed to parse payment id or address"); + fail_msg_writer() << tr("failed to parse payment ID or address"); return true; } //---------------------------------------------------------------------------------------------------- @@ -2420,7 +2420,7 @@ int main(int argc, char* argv[]) // path. if (! default_log.empty()) { - fail_msg_writer() << sw::tr("Unexpected empty log file name in presence of non-empty file path"); + fail_msg_writer() << sw::tr("unexpected empty log file name in presence of non-empty file path"); return false; } // epee didn't find path to executable from argv[0], so use this default file name. @@ -2456,7 +2456,7 @@ int main(int argc, char* argv[]) { success_msg_writer() << CRYPTONOTE_NAME << " " << sw::tr("wallet") << " v" << MONERO_VERSION_FULL; success_msg_writer() << sw::tr("Usage:") << " simplewallet [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]"; - success_msg_writer() << desc_all << '\n' << w.get_commands_str(); + success_msg_writer() << desc_all; return false; } else if (command_line::get_arg(vm, command_line::arg_version)) diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index 0c33b942e..822ccfb11 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -474,7 +474,6 @@ inline bool do_replay_events(std::vector<test_event_entry>& events) { boost::program_options::options_description desc("Allowed options"); cryptonote::core::init_options(desc); - command_line::add_arg(desc, command_line::arg_data_dir); boost::program_options::variables_map vm; bool r = command_line::handle_error_helper(desc, [&]() { @@ -485,6 +484,10 @@ inline bool do_replay_events(std::vector<test_event_entry>& events) if (!r) return false; + // hardcode a --fakechain option for tests + static const char * const fakechain[] = {"", "--fakechain"}; + boost::program_options::store(boost::program_options::parse_command_line(2, fakechain, desc), vm); + cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects cryptonote::core c(&pr); // FIXME: make sure that vm has arg_testnet_on set to true or false if @@ -671,4 +674,4 @@ inline bool do_replay_file(const std::string& filename) #define CHECK_EQ(v1, v2) CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2) #define CHECK_NOT_EQ(v1, v2) CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2) #define MK_COINS(amount) (UINT64_C(amount) * COIN) -#define TESTS_DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6) +#define TESTS_DEFAULT_FEE ((uint64_t)20000000000) // 2 * pow(10, 10) diff --git a/tests/core_tests/ring_signature_1.cpp b/tests/core_tests/ring_signature_1.cpp index 15b6531c4..b37b55cca 100644 --- a/tests/core_tests/ring_signature_1.cpp +++ b/tests/core_tests/ring_signature_1.cpp @@ -144,7 +144,7 @@ gen_ring_signature_2::gen_ring_signature_2() } /** - * Bob has 4 inputs by 61 coins. He sends 4 * 61 coins to Alice, using ring signature with nmix = 3. Each Bob's input + * Bob has 4 inputs by 13 coins. He sends 4 * 13 coins to Alice, using ring signature with nmix = 3. Each Bob's input * is used as mix for 3 others. */ bool gen_ring_signature_2::generate(std::vector<test_event_entry>& events) const @@ -161,14 +161,14 @@ bool gen_ring_signature_2::generate(std::vector<test_event_entry>& events) const MAKE_NEXT_BLOCK(events, blk_2, blk_1, miner_account); // 4 MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_account); // 5 REWIND_BLOCKS(events, blk_3r, blk_3, miner_account); // <N blocks> - MAKE_TX_LIST_START(events, txs_blk_4, miner_account, bob_account, MK_COINS(61), blk_3); // 6 + N - MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(61), blk_3); // 7 + N - MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(61), blk_3); // 8 + N - MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(61), blk_3); // 9 + N + MAKE_TX_LIST_START(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 6 + N + MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 7 + N + MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 8 + N + MAKE_TX_LIST(events, txs_blk_4, miner_account, bob_account, MK_COINS(13), blk_3); // 9 + N MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, miner_account, txs_blk_4); // 10 + N DO_CALLBACK(events, "check_balances_1"); // 11 + N REWIND_BLOCKS(events, blk_4r, blk_4, miner_account); // <N blocks> - MAKE_TX_MIX(events, tx_0, bob_account, alice_account, MK_COINS(244) - TESTS_DEFAULT_FEE, 3, blk_4); // 12 + 2N + MAKE_TX_MIX(events, tx_0, bob_account, alice_account, MK_COINS(52) - TESTS_DEFAULT_FEE, 3, blk_4); // 12 + 2N MAKE_NEXT_BLOCK_TX1(events, blk_5, blk_4r, miner_account, tx_0); // 13 + 2N DO_CALLBACK(events, "check_balances_2"); // 14 + 2N @@ -190,7 +190,7 @@ bool gen_ring_signature_2::check_balances_1(cryptonote::core& c, size_t ev_index map_hash2tx_t mtx; r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back())); CHECK_TEST_CONDITION(r); - CHECK_EQ(MK_COINS(244), get_balance(m_bob_account, chain, mtx)); + CHECK_EQ(MK_COINS(52), get_balance(m_bob_account, chain, mtx)); CHECK_EQ(0, get_balance(m_alice_account, chain, mtx)); return true; @@ -209,7 +209,7 @@ bool gen_ring_signature_2::check_balances_2(cryptonote::core& c, size_t ev_index r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back())); CHECK_TEST_CONDITION(r); CHECK_EQ(0, get_balance(m_bob_account, chain, mtx)); - CHECK_EQ(MK_COINS(244) - TESTS_DEFAULT_FEE, get_balance(m_alice_account, chain, mtx)); + CHECK_EQ(MK_COINS(52) - TESTS_DEFAULT_FEE, get_balance(m_alice_account, chain, mtx)); return true; } diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp index 308ef2997..125cad82c 100644 --- a/tests/unit_tests/block_reward.cpp +++ b/tests/unit_tests/block_reward.cpp @@ -40,7 +40,7 @@ namespace class block_reward_and_already_generated_coins : public ::testing::Test { protected: - static const size_t current_block_size = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE / 2; + static const size_t current_block_size = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 / 2; bool m_block_not_too_big; uint64_t m_block_reward; @@ -81,7 +81,7 @@ namespace { m_block_not_too_big = get_block_reward(0, 0, already_generated_coins, m_standard_block_reward, 1); ASSERT_TRUE(m_block_not_too_big); - ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward); + ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1, m_standard_block_reward); } void do_test(size_t median_block_size, size_t current_block_size) @@ -98,28 +98,28 @@ namespace TEST_F(block_reward_and_current_block_size, handles_block_size_less_relevance_level) { - do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE - 1); + do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 - 1); ASSERT_TRUE(m_block_not_too_big); ASSERT_EQ(m_block_reward, m_standard_block_reward); } TEST_F(block_reward_and_current_block_size, handles_block_size_eq_relevance_level) { - do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); + do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); ASSERT_TRUE(m_block_not_too_big); ASSERT_EQ(m_block_reward, m_standard_block_reward); } TEST_F(block_reward_and_current_block_size, handles_block_size_gt_relevance_level) { - do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE + 1); + do_test(0, CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 + 1); ASSERT_TRUE(m_block_not_too_big); ASSERT_LT(m_block_reward, m_standard_block_reward); } TEST_F(block_reward_and_current_block_size, handles_block_size_less_2_relevance_level) { - do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE - 1); + do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 - 1); ASSERT_TRUE(m_block_not_too_big); ASSERT_LT(m_block_reward, m_standard_block_reward); ASSERT_LT(0, m_block_reward); @@ -127,14 +127,14 @@ namespace TEST_F(block_reward_and_current_block_size, handles_block_size_eq_2_relevance_level) { - do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); + do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); ASSERT_TRUE(m_block_not_too_big); ASSERT_EQ(0, m_block_reward); } TEST_F(block_reward_and_current_block_size, handles_block_size_gt_2_relevance_level) { - do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE + 1); + do_test(0, 2 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 + 1); ASSERT_FALSE(m_block_not_too_big); } @@ -160,17 +160,17 @@ namespace protected: virtual void SetUp() { - m_last_block_sizes.push_back(3 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); - m_last_block_sizes.push_back(5 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); - m_last_block_sizes.push_back(7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); - m_last_block_sizes.push_back(11 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); - m_last_block_sizes.push_back(13 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE); + m_last_block_sizes.push_back(3 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); + m_last_block_sizes.push_back(5 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); + m_last_block_sizes.push_back(7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); + m_last_block_sizes.push_back(11 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); + m_last_block_sizes.push_back(13 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1); - m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE; + m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1; m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward, 1); ASSERT_TRUE(m_block_not_too_big); - ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward); + ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1, m_standard_block_reward); } void do_test(size_t current_block_size) diff --git a/tests/unit_tests/checkpoints.cpp b/tests/unit_tests/checkpoints.cpp index 2f70791c5..85a8c9a90 100644 --- a/tests/unit_tests/checkpoints.cpp +++ b/tests/unit_tests/checkpoints.cpp @@ -35,7 +35,7 @@ using namespace cryptonote; -TEST(checkpoints_is_alternative_block_allowed, handles_empty_checkpoins) +TEST(checkpoints_is_alternative_block_allowed, handles_empty_checkpoints) { checkpoints cp; |