Skip to content

Commit 5997d5c

Browse files
committed
fix note detection
1 parent 0357d18 commit 5997d5c

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/wallet/wallet.cpp

+10-13
Original file line numberDiff line numberDiff line change
@@ -3393,12 +3393,13 @@ mapSproutNoteData_t CWallet::FindMySproutNotes(const CTransaction &tx) const
33933393
* the result of FindMySaplingNotes (for the addresses available at the time) will
33943394
* already have been cached in CWalletTx.mapSaplingNoteData.
33953395
*/
3396-
static void DecryptSaplingNoteWorker(const CWallet *wallet, std::vector<const SaplingIncomingViewingKey*> vIvk, std::vector<const OutputDescription*> vOutput, std::vector<uint32_t> vPosition, const uint256 hash, const int &height, mapSaplingNoteData_t *noteData, SaplingIncomingViewingKeyMap *viewingKeysToAdd)
3396+
static void DecryptSaplingNoteWorker(const CWallet *wallet, std::vector<const SaplingIncomingViewingKey*> vIvk, std::vector<const OutputDescription*> vOutput, std::vector<uint32_t> vPosition, const uint256 hash, const int &height, mapSaplingNoteData_t *noteData, SaplingIncomingViewingKeyMap *viewingKeysToAdd, int threadNumber)
33973397
{
33983398
for (int i = 0; i < vIvk.size(); i++) {
33993399
const SaplingIncomingViewingKey ivk = *vIvk[i];
3400+
const OutputDescription output = *vOutput[i];
34003401

3401-
auto result = SaplingNotePlaintext::decrypt(Params().GetConsensus(), height, vOutput[i]->encCiphertext, ivk, vOutput[i]->ephemeralKey, vOutput[i]->cmu);
3402+
auto result = SaplingNotePlaintext::decrypt(Params().GetConsensus(), height, output.encCiphertext, ivk, output.ephemeralKey, output.cmu);
34023403
if (result) {
34033404

34043405
auto address = ivk.address(result.get().d);
@@ -3457,14 +3458,9 @@ std::pair<mapSaplingNoteData_t, SaplingIncomingViewingKeyMap> CWallet::FindMySap
34573458

34583459
// Protocol Spec: 4.19 Block Chain Scanning (Sapling)
34593460
int t = 0;
3460-
for (uint32_t i = 0; i < tx.vShieldedOutput.size(); ++i) {
3461-
// const OutputDescription output = tx.vShieldedOutput[i];
3462-
3463-
3464-
for (auto it = setSaplingIncomingViewingKeys.begin(); it != setSaplingIncomingViewingKeys.end(); ++it) {
3465-
const SaplingIncomingViewingKey ivk = *it;
3466-
3467-
vvIvk[t].emplace_back(&ivk);
3461+
for (uint32_t i = 0; i < tx.vShieldedOutput.size(); i++) {
3462+
for (auto it = setSaplingIncomingViewingKeys.begin(); it != setSaplingIncomingViewingKeys.end(); it++) {
3463+
vvIvk[t].emplace_back(&(*it));
34683464
vvOutputDescrition[t].emplace_back(&tx.vShieldedOutput[i]);
34693465
vvPosition[t].emplace_back(i);
34703466
//Increment ivk vector
@@ -3473,13 +3469,14 @@ std::pair<mapSaplingNoteData_t, SaplingIncomingViewingKeyMap> CWallet::FindMySap
34733469
if (t >= vvIvk.size()) {
34743470
t = 0;
34753471
}
3476-
34773472
}
34783473
}
34793474

34803475
std::vector<boost::thread*> decryptionThreads;
3481-
for (int i = 0; i < vvIvk.size(); i++) {
3482-
decryptionThreads.emplace_back(new boost::thread(DecryptSaplingNoteWorker, this, vvIvk[i], vvOutputDescrition[i], vvPosition[i], hash, height, &noteData, &viewingKeysToAdd));
3476+
for (int i = 0; i < vvIvk.size(); ++i) {
3477+
if(!vvIvk.empty()) {
3478+
decryptionThreads.emplace_back(new boost::thread(DecryptSaplingNoteWorker, this, vvIvk[i], vvOutputDescrition[i], vvPosition[i], hash, height, &noteData, &viewingKeysToAdd, i));
3479+
}
34833480
}
34843481

34853482
// Cleanup

0 commit comments

Comments
 (0)