From a581fe2aaef4bdd7f3c3969b0ce719642f0201d9 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 14 Oct 2016 09:03:59 -0500 Subject: [PATCH] Only ignore runtime errors caused by failed note decryption --- src/wallet/gtest/test_wallet.cpp | 8 +++++++- src/wallet/wallet.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 5b485be15..6939ae2b7 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -425,13 +425,19 @@ TEST(wallet_tests, FindMyNotes) { CWallet wallet; auto sk = libzcash::SpendingKey::random(); - wallet.AddSpendingKey(sk); + auto sk2 = libzcash::SpendingKey::random(); + wallet.AddSpendingKey(sk2); auto wtx = GetValidReceive(sk, 10, true); auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); auto noteMap = wallet.FindMyNotes(wtx); + EXPECT_EQ(0, noteMap.size()); + + wallet.AddSpendingKey(sk); + + noteMap = wallet.FindMyNotes(wtx); EXPECT_EQ(2, noteMap.size()); JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 69c30b24d..70c87dad5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1187,7 +1187,12 @@ mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const noteData.insert(std::make_pair(jsoutpt, nd)); } break; - } catch (const std::runtime_error &) { + } catch (const std::runtime_error &err) { + if (memcmp("Could not decrypt message", err.what(), 25) != 0) { + // Unexpected failure + LogPrintf("FindMyNotes(): Unexpected runtime error while testing decrypt:\n"); + LogPrintf("%s\n", err.what()); + } // else // Couldn't decrypt with this decryptor } catch (const std::exception &exc) { // Unexpected failure