From 5513faccf66f99f073dfc17b8f8cf6649b8acf2d Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 6 Oct 2018 12:18:56 +0100 Subject: [PATCH] Ignore decoding errors during -zapwallettxes The undecoded wallet transaction is logged before proceeding, so later recovery of metadata might be possible. But the fact that the user is using -zapwallettxes is a clear indicator that they want transactions removed from their wallet, so this is the priority. --- src/wallet/walletdb.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 9a878491c..1081e9d09 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1015,11 +1015,20 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector& vTxHash, vec uint256 hash; ssKey >> hash; - CWalletTx wtx; - ssValue >> wtx; + std::vector txData(ssValue.begin(), ssValue.end()); + try { + CWalletTx wtx; + ssValue >> wtx; + vWtx.push_back(wtx); + } catch (...) { + // Decode failure likely due to Sapling v4 transaction format change + // between 2.0.0 and 2.0.1. As user is requesting deletion, log the + // transaction entry and then mark it for deletion anyway. + LogPrintf("Failed to decode wallet transaction; logging it here before deletion:\n"); + LogPrintf("txid: %s\n%s\n", hash.GetHex(), HexStr(txData)); + } vTxHash.push_back(hash); - vWtx.push_back(wtx); } } pcursor->close();