Refactor GetSaplingWitnesses code and add some logging

This commit is contained in:
Duke Leto
2020-06-17 00:04:55 -04:00
parent 7f7876d208
commit 4de60497c8
2 changed files with 9 additions and 5 deletions

View File

@@ -1719,16 +1719,19 @@ void CWallet::GetSaplingNoteWitnesses(std::vector<SaplingOutPoint> notes,
boost::optional<uint256> 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);
}

View File

@@ -1,3 +1,4 @@
// Copyright (c) 2019-2020 The Hush developers
#ifndef ZC_ZCASH_H_
#define ZC_ZCASH_H_