Skip to content

Commit bb1f1c9

Browse files
committed
[Qt] importwallet progress
1 parent bbe53f6 commit bb1f1c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rpcdump.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@ Value importwallet(const Array& params, bool fHelp)
153153
EnsureWalletIsUnlocked();
154154

155155
ifstream file;
156-
file.open(params[0].get_str().c_str());
156+
file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate);
157157
if (!file.is_open())
158158
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
159159

160160
int64_t nTimeBegin = chainActive.Tip()->nTime;
161161

162162
bool fGood = true;
163163

164+
int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
165+
file.seekg(0, file.beg);
166+
167+
pwalletMain->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
164168
while (file.good()) {
169+
pwalletMain->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
165170
std::string line;
166171
std::getline(file, line);
167172
if (line.empty() || line[0] == '#')
@@ -207,6 +212,7 @@ Value importwallet(const Array& params, bool fHelp)
207212
nTimeBegin = std::min(nTimeBegin, nTime);
208213
}
209214
file.close();
215+
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
210216

211217
CBlockIndex *pindex = chainActive.Tip();
212218
while (pindex && pindex->pprev && pindex->nTime > nTimeBegin - 7200)

0 commit comments

Comments
 (0)