|
|
@ -149,7 +149,7 @@ UniValue importprivkey(const JSONRPCRequest& request) |
|
|
|
pwallet->UpdateTimeFirstKey(1); |
|
|
|
pwallet->UpdateTimeFirstKey(1); |
|
|
|
|
|
|
|
|
|
|
|
if (fRescan) { |
|
|
|
if (fRescan) { |
|
|
|
pwallet->ScanForWalletTransactions(chainActive.Genesis(), true); |
|
|
|
pwallet->RescanFromTime(TIMESTAMP_MIN, true /* update */); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -279,7 +279,7 @@ UniValue importaddress(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
if (fRescan) |
|
|
|
if (fRescan) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pwallet->ScanForWalletTransactions(chainActive.Genesis(), true); |
|
|
|
pwallet->RescanFromTime(TIMESTAMP_MIN, true /* update */); |
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -437,7 +437,7 @@ UniValue importpubkey(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
if (fRescan) |
|
|
|
if (fRescan) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pwallet->ScanForWalletTransactions(chainActive.Genesis(), true); |
|
|
|
pwallet->RescanFromTime(TIMESTAMP_MIN, true /* update */); |
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -537,11 +537,7 @@ UniValue importwallet(const JSONRPCRequest& request) |
|
|
|
file.close(); |
|
|
|
file.close(); |
|
|
|
pwallet->ShowProgress("", 100); // hide progress dialog in GUI
|
|
|
|
pwallet->ShowProgress("", 100); // hide progress dialog in GUI
|
|
|
|
pwallet->UpdateTimeFirstKey(nTimeBegin); |
|
|
|
pwallet->UpdateTimeFirstKey(nTimeBegin); |
|
|
|
|
|
|
|
pwallet->RescanFromTime(nTimeBegin - TIMESTAMP_WINDOW, false /* update */); |
|
|
|
CBlockIndex *pindex = chainActive.FindEarliestAtLeast(nTimeBegin - TIMESTAMP_WINDOW); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogPrintf("Rescanning last %i blocks\n", pindex ? chainActive.Height() - pindex->nHeight + 1 : 0); |
|
|
|
|
|
|
|
pwallet->ScanForWalletTransactions(pindex); |
|
|
|
|
|
|
|
pwallet->MarkDirty(); |
|
|
|
pwallet->MarkDirty(); |
|
|
|
|
|
|
|
|
|
|
|
if (!fGood) |
|
|
|
if (!fGood) |
|
|
@ -1117,14 +1113,10 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (fRescan && fRunScan && requests.size()) { |
|
|
|
if (fRescan && fRunScan && requests.size()) { |
|
|
|
CBlockIndex* pindex = nLowestTimestamp > minimumTimestamp ? chainActive.FindEarliestAtLeast(std::max<int64_t>(nLowestTimestamp - TIMESTAMP_WINDOW, 0)) : chainActive.Genesis(); |
|
|
|
int64_t scannedTime = pwallet->RescanFromTime(nLowestTimestamp - TIMESTAMP_WINDOW, true /* update */); |
|
|
|
CBlockIndex* scanFailed = nullptr; |
|
|
|
|
|
|
|
if (pindex) { |
|
|
|
|
|
|
|
scanFailed = pwallet->ScanForWalletTransactions(pindex, true); |
|
|
|
|
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
pwallet->ReacceptWalletTransactions(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scanFailed) { |
|
|
|
if (scannedTime > nLowestTimestamp - TIMESTAMP_WINDOW) { |
|
|
|
std::vector<UniValue> results = response.getValues(); |
|
|
|
std::vector<UniValue> results = response.getValues(); |
|
|
|
response.clear(); |
|
|
|
response.clear(); |
|
|
|
response.setArray(); |
|
|
|
response.setArray(); |
|
|
@ -1134,7 +1126,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) |
|
|
|
// range, or if the import result already has an error set, let
|
|
|
|
// range, or if the import result already has an error set, let
|
|
|
|
// the result stand unmodified. Otherwise replace the result
|
|
|
|
// the result stand unmodified. Otherwise replace the result
|
|
|
|
// with an error message.
|
|
|
|
// with an error message.
|
|
|
|
if (GetImportTimestamp(request, now) - TIMESTAMP_WINDOW > scanFailed->GetBlockTimeMax() || results.at(i).exists("error")) { |
|
|
|
if (scannedTime <= GetImportTimestamp(request, now) - TIMESTAMP_WINDOW || results.at(i).exists("error")) { |
|
|
|
response.push_back(results.at(i)); |
|
|
|
response.push_back(results.at(i)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
UniValue result = UniValue(UniValue::VOBJ); |
|
|
|
UniValue result = UniValue(UniValue::VOBJ); |
|
|
@ -1150,7 +1142,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) |
|
|
|
"caused by pruning or data corruption (see bitcoind log for details) and could " |
|
|
|
"caused by pruning or data corruption (see bitcoind log for details) and could " |
|
|
|
"be dealt with by downloading and rescanning the relevant blocks (see -reindex " |
|
|
|
"be dealt with by downloading and rescanning the relevant blocks (see -reindex " |
|
|
|
"and -rescan options).", |
|
|
|
"and -rescan options).", |
|
|
|
GetImportTimestamp(request, now), scanFailed->GetBlockTimeMax(), TIMESTAMP_WINDOW))); |
|
|
|
GetImportTimestamp(request, now), scannedTime - 1, TIMESTAMP_WINDOW))); |
|
|
|
response.push_back(std::move(result)); |
|
|
|
response.push_back(std::move(result)); |
|
|
|
} |
|
|
|
} |
|
|
|
++i; |
|
|
|
++i; |
|
|
|