aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blockchain_utilities/blockchain_import.cpp23
-rw-r--r--src/cryptonote_core/blockchain_storage.h3
-rw-r--r--src/simplewallet/simplewallet.cpp8
-rw-r--r--src/simplewallet/simplewallet.h1
4 files changed, 26 insertions, 9 deletions
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index fc00cdcba..aeed2b335 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -142,8 +142,12 @@ int pop_blocks(FakeCore& simple_core, int num_blocks)
std::vector<transaction> popped_txs;
for (int i=0; i < num_blocks; ++i)
{
+#if defined(BLOCKCHAIN_DB) && (BLOCKCHAIN_DB == DB_MEMORY)
+ simple_core.m_storage.debug_pop_block_from_blockchain();
+#else
// simple_core.m_storage.pop_block_from_blockchain() is private, so call directly through db
simple_core.m_storage.get_db().pop_block(popped_block, popped_txs);
+#endif
quit = 1;
}
@@ -615,12 +619,12 @@ int main(int argc, char* argv[])
if (! opt_batch && ! vm["batch-size"].defaulted())
{
std::cerr << "Error: batch-size set, but batch option not enabled" << ENDL;
- exit(1);
+ return 1;
}
if (! db_batch_size)
{
std::cerr << "Error: batch-size must be > 0" << ENDL;
- exit(1);
+ return 1;
}
if (opt_verify && vm["batch-size"].defaulted())
{
@@ -655,7 +659,7 @@ int main(int argc, char* argv[])
{
BootstrapFile bootstrap;
bootstrap.count_blocks(import_file_path);
- exit(0);
+ return 0;
}
@@ -666,13 +670,13 @@ int main(int argc, char* argv[])
if (res)
{
std::cerr << "Error parsing database argument(s)" << ENDL;
- exit(1);
+ return 1;
}
if (std::find(db_engines.begin(), db_engines.end(), db_engine) == db_engines.end())
{
std::cerr << "Invalid database engine: " << db_engine << std::endl;
- exit(1);
+ return 1;
}
LOG_PRINT_L0("database: " << db_engine);
@@ -717,7 +721,7 @@ int main(int argc, char* argv[])
else
{
std::cerr << "database engine unrecognized" << ENDL;
- exit(1);
+ return 1;
}
// for multi_db_compile:
@@ -725,7 +729,7 @@ int main(int argc, char* argv[])
if (db_engine != default_db_engine)
{
std::cerr << "Invalid database engine for compiled version: " << db_engine << std::endl;
- exit(1);
+ return 1;
}
#if BLOCKCHAIN_DB == DB_LMDB
fake_core_lmdb simple_core(dirname, opt_testnet, opt_batch, mdb_flags);
@@ -739,7 +743,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("height: " << simple_core.m_storage.get_current_blockchain_height());
pop_blocks(simple_core, num_blocks);
LOG_PRINT_L0("height: " << simple_core.m_storage.get_current_blockchain_height());
- exit(0);
+ return 0;
}
import_from_file(simple_core, import_file_path, block_stop);
@@ -749,7 +753,7 @@ int main(int argc, char* argv[])
catch (const DB_ERROR& e)
{
std::cout << std::string("Error loading blockchain db: ") + e.what() + " -- shutting down now" << ENDL;
- exit(1);
+ return 1;
}
// destructors called at exit:
@@ -762,4 +766,5 @@ int main(int argc, char* argv[])
// LMDB fake_core, it calls Blockchain::deinit() on its object, which in turn
// calls delete on its BlockchainDB derived class' object, which closes its
// files.
+ return 0;
}
diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h
index 50a62a428..2c2fb5250 100644
--- a/src/cryptonote_core/blockchain_storage.h
+++ b/src/cryptonote_core/blockchain_storage.h
@@ -190,6 +190,9 @@ namespace cryptonote
difficulty_type get_block_cumulative_difficulty(uint64_t height) const { return m_blocks[height].cumulative_difficulty; }
uint64_t get_block_coins_generated(uint64_t height) const { return m_blocks[height].already_generated_coins; }
+ // use for testing only
+ bool debug_pop_block_from_blockchain() { return pop_block_from_blockchain(); }
+
private:
typedef std::unordered_map<crypto::hash, size_t> blocks_by_id_index;
typedef std::unordered_map<crypto::hash, transaction_chain_entry> transactions_container;
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 9ac80fa9e..2b2488952 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -208,6 +208,13 @@ bool simple_wallet::viewkey(const std::vector<std::string> &args/* = std::vector
return true;
}
+bool simple_wallet::spendkey(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
+{
+ success_msg_writer() << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key) << std::endl;
+
+ return true;
+}
+
bool simple_wallet::seed(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
bool success = false;
@@ -288,6 +295,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), "Show current wallet public address");
m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), "Save wallet synchronized data");
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), "Get viewkey");
+ m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), "Get spendkey");
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), "Get deterministic seed");
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), "available options: seed language - Set wallet seed langage");
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), "Show this help");
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index a8fe78414..de5b3674e 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -80,6 +80,7 @@ namespace cryptonote
bool close_wallet();
bool viewkey(const std::vector<std::string> &args = std::vector<std::string>());
+ bool spendkey(const std::vector<std::string> &args = std::vector<std::string>());
bool seed(const std::vector<std::string> &args = std::vector<std::string>());
/*!