You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An off-by-one-block bug in importmulti rescan logic could cause it to return
success in an edge case even when a rescan was not successful. The case where
this would happen is if there were multiple blocks in a row with the same
GetBlockTimeMax() value, and the last block was scanned successfully, but one
or more of the earlier blocks was not readable.
// range, or if the import result already has an error set, let
1138
1138
// the result stand unmodified. Otherwise replace the result
1139
1139
// with an error message.
1140
-
if (GetImportTimestamp(request, now) - TIMESTAMP_WINDOW >= scannedRange->GetBlockTimeMax() || results.at(i).exists("error")) {
1140
+
if (GetImportTimestamp(request, now) - TIMESTAMP_WINDOW > scanFailed->GetBlockTimeMax() || results.at(i).exists("error")) {
1141
1141
response.push_back(results.at(i));
1142
1142
} else {
1143
1143
UniValue result = UniValue(UniValue::VOBJ);
1144
1144
result.pushKV("success", UniValue(false));
1145
-
result.pushKV("error", JSONRPCError(RPC_MISC_ERROR, strprintf("Failed to rescan before time %d, transactions may be missing.", scannedRange->GetBlockTimeMax())));
1145
+
result.pushKV(
1146
+
"error",
1147
+
JSONRPCError(
1148
+
RPC_MISC_ERROR,
1149
+
strprintf("Rescan failed for key with creation timestamp %d. There was an error reading a "
1150
+
"block from time %d, which is after or within %d seconds of key creation, and "
1151
+
"could contain transactions pertaining to the key. As a result, transactions "
1152
+
"and coins using this key may not appear in the wallet. This error could be "
1153
+
"caused by pruning or data corruption (see bitcoind log for details) and could "
1154
+
"be dealt with by downloading and rescanning the relevant blocks (see -reindex "
BOOST_CHECK_EQUAL(response.write(), strprintf("[{\"success\":false,\"error\":{\"code\":-1,\"message\":\"Failed to rescan before time %d, transactions may be missing.\"}},{\"success\":true}]", newTip->GetBlockTimeMax()));
425
+
BOOST_CHECK_EQUAL(response.write(),
426
+
strprintf("[{\"success\":false,\"error\":{\"code\":-1,\"message\":\"Rescan failed for key with creation "
427
+
"timestamp %d. There was an error reading a block from time %d, which is after or within %d "
428
+
"seconds of key creation, and could contain transactions pertaining to the key. As a result, "
429
+
"transactions and coins using this key may not appear in the wallet. This error could be caused "
430
+
"by pruning or data corruption (see bitcoind log for details) and could be dealt with by "
431
+
"downloading and rescanning the relevant blocks (see -reindex and -rescan "
432
+
"options).\"}},{\"success\":true}]",
433
+
0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW));
425
434
::pwalletMain = backup;
426
435
}
427
-
428
-
// Verify ScanForWalletTransactions does not return null when the scan is
0 commit comments