aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-30 12:58:15 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-30 15:06:03 +0000
commitbc8a52efd8dcda4544856e724a17c9cba161d4a2 (patch)
tree579f443671f7922979940a14f90ddd5f4e38273b /src/simplewallet
parentwallet: protect against exceptions in the block pull thread (diff)
downloadmonero-bc8a52efd8dcda4544856e724a17c9cba161d4a2.tar.xz
wallet: add a rescan_bc command and rescan_blockchain RPC
Blockchain hashes and key images are flushed, and blocks are pulled anew from the daemon. The console command is shortened to match bc_height. This should make it a lot easier on users who are currently told to remove this particular cache file but keep the keys one, etc, etc.
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp39
-rw-r--r--src/simplewallet/simplewallet.h2
2 files changed, 28 insertions, 13 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index ad4cd5622..b8586bf17 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -551,6 +551,7 @@ simple_wallet::simple_wallet()
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("rescan_bc", boost::bind(&simple_wallet::rescan_blockchain, this, _1), tr("Rescan blockchain from scratch"));
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help"));
}
//----------------------------------------------------------------------------------------------------
@@ -1324,7 +1325,7 @@ void simple_wallet::on_skip_transaction(uint64_t height, const cryptonote::trans
m_refresh_progress_reporter.update(height, true);
}
//----------------------------------------------------------------------------------------------------
-bool simple_wallet::refresh(const std::vector<std::string>& args)
+bool simple_wallet::refresh_main(uint64_t start_height, bool reset)
{
if (!try_connect_to_daemon())
return true;
@@ -1336,21 +1337,12 @@ bool simple_wallet::refresh(const std::vector<std::string>& args)
std::unique_lock<std::mutex> lock(m_auto_refresh_mutex);
m_auto_refresh_cond.notify_one();
+ if (reset)
+ m_wallet->rescan_blockchain(false);
+
message_writer() << tr("Starting refresh...");
uint64_t fetched_blocks = 0;
- uint64_t start_height = 0;
- if(!args.empty()){
- try
- {
- start_height = boost::lexical_cast<uint64_t>( args[0] );
- }
- catch(const boost::bad_lexical_cast &)
- {
- start_height = 0;
- }
- }
-
bool ok = false;
std::ostringstream ss;
try
@@ -1408,6 +1400,22 @@ bool simple_wallet::refresh(const std::vector<std::string>& args)
return true;
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::refresh(const std::vector<std::string>& args)
+{
+ uint64_t start_height = 0;
+ if(!args.empty()){
+ try
+ {
+ start_height = boost::lexical_cast<uint64_t>( args[0] );
+ }
+ catch(const boost::bad_lexical_cast &)
+ {
+ start_height = 0;
+ }
+ }
+ return refresh_main(start_height, false);
+}
+//----------------------------------------------------------------------------------------------------
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()) << ", "
@@ -2276,6 +2284,11 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
return true;
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::rescan_blockchain(const std::vector<std::string> &args_)
+{
+ return refresh_main(0, true);
+}
+//----------------------------------------------------------------------------------------------------
void simple_wallet::wallet_refresh_thread()
{
while (true)
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index ef44d5374..486e197ae 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -132,6 +132,8 @@ namespace cryptonote
bool get_tx_key(const std::vector<std::string> &args);
bool check_tx_key(const std::vector<std::string> &args);
bool show_transfers(const std::vector<std::string> &args);
+ bool rescan_blockchain(const std::vector<std::string> &args);
+ bool refresh_main(uint64_t start_height, bool reset = false);
uint64_t get_daemon_blockchain_height(std::string& err);
bool try_connect_to_daemon();