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:
0--- a/src/wallet/walletdb.cpp
1+++ b/src/wallet/walletdb.cpp
2@@ -256,6 +256,7 @@ public:
3 std::map<std::pair<uint256, CKeyID>, CKey> m_descriptor_keys;
4 std::map<std::pair<uint256, CKeyID>, std::pair<CPubKey, std::vector<unsigned char>>> m_descriptor_crypt_keys;
5 std::map<uint160, CHDChain> m_hd_chains;
6+ bool corrupt = false;
7
8 CWalletScanState() {
9 }
10@@ -289,6 +290,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
11 if (!new_tx) {
12 // There's probably some corruption here since the tx we just tried to load was already in the wallet
13 // This error is recoverable with zapwallettxs and is not a major failure
14+ wss.corrupt = true;
15 return false;
16 }
17 ssValue >> wtx;
18@@ -730,7 +732,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
19 {
20 // losing keys is considered a catastrophic error, anything else
21 // we assume the user can live with:
22- if (IsKeyType(strType) || strType == DBKeys::DEFAULTKEY) {
23+ if (IsKeyType(strType) || strType == DBKeys::DEFAULTKEY || wss.corrupt) {
24 result = DBErrors::CORRUPT;
25 } else if (strType == DBKeys::FLAGS) {
26 // reading the wallet flags can only fail if unknown flags are present