aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interfaces/wallet.cpp1
-rw-r--r--src/interfaces/wallet.h3
-rw-r--r--src/qt/walletview.cpp11
-rw-r--r--src/wallet/rpcdump.cpp8
4 files changed, 17 insertions, 6 deletions
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index 0244fe70f5..ecc073f9bc 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -132,6 +132,7 @@ public:
{
return m_wallet.ChangeWalletPassphrase(old_wallet_passphrase, new_wallet_passphrase);
}
+ void abortRescan() override { m_wallet.AbortRescan(); }
bool backupWallet(const std::string& filename) override { return m_wallet.BackupWallet(filename); }
std::string getWalletName() override { return m_wallet.GetName(); }
bool getKeyFromPool(bool internal, CPubKey& pub_key) override
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
index 3e27242c2c..dfe3d5f711 100644
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -65,6 +65,9 @@ public:
virtual bool changeWalletPassphrase(const SecureString& old_wallet_passphrase,
const SecureString& new_wallet_passphrase) = 0;
+ //! Abort a rescan.
+ virtual void abortRescan() = 0;
+
//! Back up wallet.
virtual bool backupWallet(const std::string& filename) = 0;
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index 8b9b85c8c9..d529595dec 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -315,9 +315,9 @@ void WalletView::showProgress(const QString &title, int nProgress)
progressDialog = new QProgressDialog(title, "", 0, 100);
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
- progressDialog->setCancelButton(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
+ progressDialog->setCancelButtonText(tr("Cancel"));
}
else if (nProgress == 100)
{
@@ -327,8 +327,13 @@ void WalletView::showProgress(const QString &title, int nProgress)
progressDialog->deleteLater();
}
}
- else if (progressDialog)
- progressDialog->setValue(nProgress);
+ else if (progressDialog) {
+ if (progressDialog->wasCanceled()) {
+ getWalletModel()->wallet().abortRescan();
+ } else {
+ progressDialog->setValue(nProgress);
+ }
+ }
}
void WalletView::requestedSyncWarningInfo()
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index a3594aa692..55cdbdb145 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -534,9 +534,11 @@ UniValue importwallet(const JSONRPCRequest& request)
int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
file.seekg(0, file.beg);
- pwallet->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
+ // Use uiInterface.ShowProgress instead of pwallet.ShowProgress because pwallet.ShowProgress has a cancel button tied to AbortRescan which
+ // we don't want for this progress bar shoing the import progress. uiInterface.ShowProgress does not have a cancel button.
+ uiInterface.ShowProgress(_("Importing..."), 0, false); // show progress dialog in GUI
while (file.good()) {
- pwallet->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
+ uiInterface.ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))), false);
std::string line;
std::getline(file, line);
if (line.empty() || line[0] == '#')
@@ -599,7 +601,7 @@ UniValue importwallet(const JSONRPCRequest& request)
}
}
file.close();
- pwallet->ShowProgress("", 100); // hide progress dialog in GUI
+ uiInterface.ShowProgress("", 100, false); // hide progress dialog in GUI
pwallet->UpdateTimeFirstKey(nTimeBegin);
}
pwallet->RescanFromTime(nTimeBegin, reserver, false /* update */);