diff options
author | Howard Chu <hyc@symas.com> | 2016-04-15 19:10:20 +0100 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2016-04-17 15:25:46 +0100 |
commit | 19fe8ae3ef1aa46ae8fdd4e4d6862510390ddab7 (patch) | |
tree | afd15eed0ad6133c11860c87d35be2e9f7ccab98 /src/simplewallet | |
parent | Speed up new wallet refresh (diff) | |
download | monero-19fe8ae3ef1aa46ae8fdd4e4d6862510390ddab7.tar.xz |
Add --restore-height option
For specifying the block height from which to start a restore
Diffstat (limited to 'src/simplewallet')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 24 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 46a8095fc..f6e5f2cc6 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -97,6 +97,7 @@ namespace 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<uint64_t> arg_restore_height = {"restore-height", sw::tr("Restore from specific blockchain height"), 0}; const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""}; @@ -1136,6 +1137,22 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) return false; } } + if (!m_restore_height) + { + std::string heightstr = command_line::input_line("Restore from specific blockchain height (optional, default 0): "); + if (std::cin.eof()) + return false; + if (heightstr.size()) + { + try { + m_restore_height = boost::lexical_cast<uint64_t>(heightstr); + } + catch (boost::bad_lexical_cast &) { + fail_msg_writer() << tr("bad m_restore_height parameter:") << " " << heightstr; + return false; + } + } + } if (!m_generate_from_view_key.empty()) { // parse address @@ -1306,6 +1323,7 @@ bool simple_wallet::handle_command_line(const boost::program_options::variables_ m_restore_deterministic_wallet = command_line::get_arg(vm, arg_restore_deterministic_wallet); m_non_deterministic = command_line::get_arg(vm, arg_non_deterministic); m_trusted_daemon = command_line::get_arg(vm, arg_trusted_daemon); + m_restore_height = command_line::get_arg(vm, arg_restore_height); return true; } @@ -1415,6 +1433,9 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string { std::string err; m_wallet->set_refresh_from_block_height(get_daemon_blockchain_height(err)); + } else if (m_restore_height) + { + m_wallet->set_refresh_from_block_height(m_restore_height); } // convert rng value to electrum-style word list @@ -1463,6 +1484,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string } m_wallet->init(m_daemon_address); + m_wallet->set_refresh_from_block_height(m_restore_height); return true; } @@ -1488,6 +1510,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string } m_wallet->init(m_daemon_address); + m_wallet->set_refresh_from_block_height(m_restore_height); return true; } @@ -2927,6 +2950,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_params, arg_testnet); command_line::add_arg(desc_params, arg_restricted); command_line::add_arg(desc_params, arg_trusted_daemon); + command_line::add_arg(desc_params, arg_restore_height); tools::wallet_rpc_server::init_options(desc_params); po::positional_options_description positional_options; diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 21bbfa566..87d502d67 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -231,6 +231,7 @@ namespace cryptonote bool m_restore_deterministic_wallet; // recover flag bool m_non_deterministic; // old 2-random generation bool m_trusted_daemon; + uint64_t m_restore_height; // optional std::string m_daemon_address; std::string m_daemon_host; |