aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-10-01 21:04:49 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-10-01 21:04:49 +0300
commit8b20cbfa7dcdae314ae8090b3fe0bd83deae0116 (patch)
tree75d46347b36540f1cf81e7ce7aa34d09eb0344f7 /src
parentlibwallet_api: fast-refresh in case of opening non-synced wallet (diff)
downloadmonero-8b20cbfa7dcdae314ae8090b3fe0bd83deae0116.tar.xz
libwallet_api: do not use fast-refresh on recovery
Diffstat (limited to 'src')
-rw-r--r--src/wallet/api/wallet.cpp9
-rw-r--r--src/wallet/api/wallet.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 9bb7f0569..16321a5a2 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -167,7 +167,7 @@ uint64_t Wallet::maximumAllowedAmount()
///////////////////////// WalletImpl implementation ////////////////////////
WalletImpl::WalletImpl(bool testnet)
:m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false),
- m_wallet2Callback(nullptr)
+ m_wallet2Callback(nullptr), m_recoveringFromSeed(false)
{
m_wallet = new tools::wallet2(testnet);
m_history = new TransactionHistoryImpl(this);
@@ -197,7 +197,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
{
clearStatus();
-
+ m_recoveringFromSeed = false;
bool keys_file_exists;
bool wallet_file_exists;
tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
@@ -234,6 +234,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
bool WalletImpl::open(const std::string &path, const std::string &password)
{
clearStatus();
+ m_recoveringFromSeed = false;
try {
// TODO: handle "deprecated"
m_wallet->load(path, password);
@@ -258,6 +259,7 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed)
return false;
}
+ m_recoveringFromSeed = true;
crypto::secret_key recovery_key;
std::string old_language;
if (!crypto::ElectrumWords::words_to_bytes(seed, recovery_key, old_language)) {
@@ -270,6 +272,7 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed)
m_wallet->set_seed_language(old_language);
m_wallet->generate(path, "", recovery_key, true, false);
// TODO: wallet->init(daemon_address);
+
} catch (const std::exception &e) {
m_status = Status_Error;
m_errorString = e.what();
@@ -747,7 +750,7 @@ bool WalletImpl::isNewWallet() const
// in case wallet created without daemon connection, closed and opened again,
// it's the same case as if it created from scratch, i.e. we need "fast sync"
// with the daemon (pull hashes instead of pull blocks)
- return !(blockChainHeight() > 1);
+ return !(blockChainHeight() > 1 || m_recoveringFromSeed);
}
void WalletImpl::doInit(const string &daemon_address, uint64_t upper_transaction_size_limit)
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 09db05d08..5706b2bf5 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -128,6 +128,10 @@ private:
boost::mutex m_refreshMutex2;
boost::condition_variable m_refreshCV;
boost::thread m_refreshThread;
+ // flag indicating wallet is recovering from seed
+ // so it shouldn't be considered as new and pull blocks (slow-refresh)
+ // instead of pulling hashes (fast-refresh)
+ bool m_recoveringFromSeed;
};