In commit "Return false instead of asserting when a loaded tx isn't new" (fbe8816f1a95e266b59b39327da4374a0442e279)
The fact that #19078 is hitting this is probably a result of the aggressive salvage
Maybe this change is ultimately the right one, but until we clearly understand what is happening I think it would be better to either drop this commit and follow up in a separate PR, or update the commit to ensure the error is not ignored like:
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -256,6 +256,7 @@ public:
std::map<std::pair<uint256, CKeyID>, CKey> m_descriptor_keys;
std::map<std::pair<uint256, CKeyID>, std::pair<CPubKey, std::vector<unsigned char>>> m_descriptor_crypt_keys;
std::map<uint160, CHDChain> m_hd_chains;
+ bool corrupt = false;
CWalletScanState() {
}
@@ -289,6 +290,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
if (!new_tx) {
// There's probably some corruption here since the tx we just tried to load was already in the wallet
// This error is recoverable with zapwallettxs and is not a major failure
+ wss.corrupt = true;
return false;
}
ssValue >> wtx;
@@ -730,7 +732,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
{
// losing keys is considered a catastrophic error, anything else
// we assume the user can live with:
- if (IsKeyType(strType) || strType == DBKeys::DEFAULTKEY) {
+ if (IsKeyType(strType) || strType == DBKeys::DEFAULTKEY || wss.corrupt) {
result = DBErrors::CORRUPT;
} else if (strType == DBKeys::FLAGS) {
// reading the wallet flags can only fail if unknown flags are present