@@ -1745,20 +1745,27 @@ RPCHelpMan importdescriptors()
1745
1745
if (scanned_time <= GetImportTimestamp (request, now) || results.at (i).exists (" error" )) {
1746
1746
response.push_back (results.at (i));
1747
1747
} else {
1748
+ std::string error_msg{strprintf (" Rescan failed for descriptor with timestamp %d. There "
1749
+ " was an error reading a block from time %d, which is after or within %d seconds "
1750
+ " of key creation, and could contain transactions pertaining to the desc. As a "
1751
+ " result, transactions and coins using this desc may not appear in the wallet." ,
1752
+ GetImportTimestamp (request, now), scanned_time - TIMESTAMP_WINDOW - 1 , TIMESTAMP_WINDOW)};
1753
+ if (pwallet->chain ().havePruned ()) {
1754
+ error_msg += strprintf (" This error could be caused by pruning or data corruption "
1755
+ " (see bitcoind log for details) and could be dealt with by downloading and "
1756
+ " rescanning the relevant blocks (see -reindex option and rescanblockchain RPC)." );
1757
+ } else if (pwallet->chain ().hasAssumedValidChain ()) {
1758
+ error_msg += strprintf (" This error is likely caused by an in-progress assumeutxo "
1759
+ " background sync. Check logs or getchainstates RPC for assumeutxo background "
1760
+ " sync progress and try again later." );
1761
+ } else {
1762
+ error_msg += strprintf (" This error could potentially caused by data corruption. If "
1763
+ " the issue persists you may want to reindex (see -reindex option)." );
1764
+ }
1765
+
1748
1766
UniValue result = UniValue (UniValue::VOBJ);
1749
1767
result.pushKV (" success" , UniValue (false ));
1750
- result.pushKV (
1751
- " error" ,
1752
- JSONRPCError (
1753
- RPC_MISC_ERROR,
1754
- strprintf (" Rescan failed for descriptor with timestamp %d. There was an error reading a "
1755
- " block from time %d, which is after or within %d seconds of key creation, and "
1756
- " could contain transactions pertaining to the desc. As a result, transactions "
1757
- " and coins using this desc may not appear in the wallet. This error could be "
1758
- " caused by pruning or data corruption (see bitcoind log for details) and could "
1759
- " be dealt with by downloading and rescanning the relevant blocks (see -reindex "
1760
- " option and rescanblockchain RPC)." ,
1761
- GetImportTimestamp (request, now), scanned_time - TIMESTAMP_WINDOW - 1 , TIMESTAMP_WINDOW)));
1768
+ result.pushKV (" error" , JSONRPCError (RPC_MISC_ERROR, error_msg));
1762
1769
response.push_back (std::move (result));
1763
1770
}
1764
1771
}
0 commit comments