@@ -172,7 +172,13 @@ UniValue importprivkey(const JSONRPCRequest& request)
172
172
}
173
173
}
174
174
if (fRescan ) {
175
- pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
175
+ int64_t scanned_time = pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
176
+ if (pwallet->IsAbortingRescan ()) {
177
+ throw JSONRPCError (RPC_MISC_ERROR, " Rescan aborted by user." );
178
+ }
179
+ if (scanned_time > TIMESTAMP_MIN) {
180
+ throw JSONRPCError (RPC_WALLET_ERROR, " Rescan was unable to fully rescan the blockchain. Some transactions may be missing." );
181
+ }
176
182
}
177
183
178
184
return NullUniValue;
@@ -310,7 +316,13 @@ UniValue importaddress(const JSONRPCRequest& request)
310
316
}
311
317
if (fRescan )
312
318
{
313
- pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
319
+ int64_t scanned_time = pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
320
+ if (pwallet->IsAbortingRescan ()) {
321
+ throw JSONRPCError (RPC_MISC_ERROR, " Rescan aborted by user." );
322
+ }
323
+ if (scanned_time > TIMESTAMP_MIN) {
324
+ throw JSONRPCError (RPC_WALLET_ERROR, " Rescan was unable to fully rescan the blockchain. Some transactions may be missing." );
325
+ }
314
326
pwallet->ReacceptWalletTransactions ();
315
327
}
316
328
@@ -479,7 +491,13 @@ UniValue importpubkey(const JSONRPCRequest& request)
479
491
}
480
492
if (fRescan )
481
493
{
482
- pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
494
+ int64_t scanned_time = pwallet->RescanFromTime (TIMESTAMP_MIN, reserver, true /* update */ );
495
+ if (pwallet->IsAbortingRescan ()) {
496
+ throw JSONRPCError (RPC_MISC_ERROR, " Rescan aborted by user." );
497
+ }
498
+ if (scanned_time > TIMESTAMP_MIN) {
499
+ throw JSONRPCError (RPC_WALLET_ERROR, " Rescan was unable to fully rescan the blockchain. Some transactions may be missing." );
500
+ }
483
501
pwallet->ReacceptWalletTransactions ();
484
502
}
485
503
@@ -604,7 +622,14 @@ UniValue importwallet(const JSONRPCRequest& request)
604
622
uiInterface.ShowProgress (" " , 100 , false ); // hide progress dialog in GUI
605
623
pwallet->UpdateTimeFirstKey (nTimeBegin);
606
624
}
607
- pwallet->RescanFromTime (nTimeBegin, reserver, false /* update */ );
625
+ uiInterface.ShowProgress (" " , 100 , false ); // hide progress dialog in GUI
626
+ int64_t scanned_time = pwallet->RescanFromTime (nTimeBegin, reserver, false /* update */ );
627
+ if (pwallet->IsAbortingRescan ()) {
628
+ throw JSONRPCError (RPC_MISC_ERROR, " Rescan aborted by user." );
629
+ }
630
+ if (scanned_time > nTimeBegin) {
631
+ throw JSONRPCError (RPC_WALLET_ERROR, " Rescan was unable to fully rescan the blockchain. Some transactions may be missing." );
632
+ }
608
633
pwallet->MarkDirty ();
609
634
610
635
if (!fGood )
@@ -1214,6 +1239,9 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
1214
1239
int64_t scannedTime = pwallet->RescanFromTime (nLowestTimestamp, reserver, true /* update */ );
1215
1240
pwallet->ReacceptWalletTransactions ();
1216
1241
1242
+ if (pwallet->IsAbortingRescan ()) {
1243
+ throw JSONRPCError (RPC_MISC_ERROR, " Rescan aborted by user." );
1244
+ }
1217
1245
if (scannedTime > nLowestTimestamp) {
1218
1246
std::vector<UniValue> results = response.getValues ();
1219
1247
response.clear ();
0 commit comments