From 18dd96464b5cf5e78493fb3882ebd33bef3e3e60 Mon Sep 17 00:00:00 2001 From: Derek Guenther Date: Tue, 26 Nov 2024 14:14:48 -0500 Subject: [PATCH] Pass through decryptForSpender flag to note decryption (#5671) --- ironfish/src/wallet/wallet.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ironfish/src/wallet/wallet.ts b/ironfish/src/wallet/wallet.ts index 2b9130f3b5..84f1529fea 100644 --- a/ironfish/src/wallet/wallet.ts +++ b/ironfish/src/wallet/wallet.ts @@ -41,6 +41,7 @@ import { } from '../utils' import { WorkerPool } from '../workerPool' import { DecryptedNote, DecryptNotesItem } from '../workerPool/tasks/decryptNotes' +import { DecryptNotesOptions } from '../workerPool/tasks/decryptNotes' import { Account, ACCOUNT_SCHEMA_VERSION } from './account/account' import { EncryptedAccount } from './account/encryptedAccount' import { AssetBalances } from './assetBalances' @@ -418,13 +419,21 @@ export class Wallet { } if (accounts.length * decryptNotesPayloads.length >= workloadSize) { - notePromises.push(this.decryptNotesFromTransaction(accounts, decryptNotesPayloads)) + notePromises.push( + this.decryptNotesFromTransaction(accounts, decryptNotesPayloads, { + decryptForSpender, + }), + ) decryptNotesPayloads = [] } } if (decryptNotesPayloads.length) { - notePromises.push(this.decryptNotesFromTransaction(accounts, decryptNotesPayloads)) + notePromises.push( + this.decryptNotesFromTransaction(accounts, decryptNotesPayloads, { + decryptForSpender, + }), + ) } const mergedResults: Map> = new Map() @@ -448,6 +457,7 @@ export class Wallet { private decryptNotesFromTransaction( accounts: ReadonlyArray, encryptedNotes: Array, + options: DecryptNotesOptions, ): Promise>> { const accountKeys = accounts.map((account) => ({ accountId: account.id, @@ -456,9 +466,7 @@ export class Wallet { viewKey: Buffer.from(account.viewKey, 'hex'), })) - return this.workerPool.decryptNotes(accountKeys, encryptedNotes, { - decryptForSpender: false, - }) + return this.workerPool.decryptNotes(accountKeys, encryptedNotes, options) } async connectBlockForAccount(