From 4de60497c866c82330defd63b11884ab8991f973 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 00:04:55 -0400 Subject: [PATCH] Refactor GetSaplingWitnesses code and add some logging --- src/wallet/wallet.cpp | 13 ++++++++----- src/zcash/Zcash.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a7ca3d74d..b9ad1919d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1719,16 +1719,19 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, boost::optional rt; int i = 0; for (SaplingOutPoint note : notes) { - if (mapWallet.count(note.hash) && - mapWallet[note.hash].mapSaplingNoteData.count(note) && - mapWallet[note.hash].mapSaplingNoteData[note].witnesses.size() > 0) { - witnesses[i] = mapWallet[note.hash].mapSaplingNoteData[note].witnesses.front(); + fprintf(stderr,"%s: i=%d\n", __func__,i); + auto noteData = mapWallet[note.hash].mapSaplingNoteData; + auto witnessess = noteData[note].witnesses; + if (mapWallet.count(note.hash) && noteData.count(note) && witnesses.size() > 0) { + fprintf(stderr,"%s: Found %lu witnesses for note %s\n", __func__, witnesses.size(), note.hash.ToString().c_str() ); + witnesses[i] = witnesses.front(); if (!rt) { rt = witnesses[i]->root(); } else { if(*rt == witnesses[i]->root()) { // Something is fucky - std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root!"; + std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root! i="; + err += i; throw std::logic_error(err); } diff --git a/src/zcash/Zcash.h b/src/zcash/Zcash.h index 84dfe9525..e45aa1d02 100644 --- a/src/zcash/Zcash.h +++ b/src/zcash/Zcash.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers #ifndef ZC_ZCASH_H_ #define ZC_ZCASH_H_