From 0736fa14fccddaab949cf3114ce9075341624e01 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 31 Aug 2016 21:16:59 +1200 Subject: [PATCH] Keep any existing cached witnesses when updating transactions --- src/wallet/wallet.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fe2771e66..438de40db 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -917,7 +917,16 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD } if (!wtxIn.mapNoteData.empty() && wtxIn.mapNoteData != wtx.mapNoteData) { - wtx.mapNoteData = wtxIn.mapNoteData; + auto tmp = wtxIn.mapNoteData; + // Ensure we keep any cached witnesses we may already have + for (const std::pair nd : wtx.mapNoteData) { + if (tmp.count(nd.first) && nd.second.witnesses.size() > 0) { + tmp.at(nd.first).witnesses.assign( + nd.second.witnesses.cbegin(), nd.second.witnesses.cend()); + } + } + // Now copy over the updated note data + wtx.mapNoteData = tmp; fUpdated = true; } if (wtxIn.fFromMe && wtxIn.fFromMe != wtx.fFromMe)