Skip to content

Commit

Permalink
small refactor of addTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Mar 6, 2024
1 parent f874963 commit 9c5d78a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions js/pivx_shield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,7 @@ export class PIVXShield {
await this.removeSpentNotes(res.nullifiers);
}
}
return res.decrypted_notes.filter(
(note) =>
!this.unspentNotes.some(
(note2) => JSON.stringify(note2[0]) === JSON.stringify(note[0]),
),
);
return res.decrypted_notes;
}

/**
Expand Down Expand Up @@ -386,9 +381,16 @@ export class PIVXShield {
if (useShieldInputs) {
this.pendingSpentNotes.set(txid, nullifiers);
}
const decryptedNewNotes = (await this.addTransaction(txhex, true)).filter(
(note) =>
!this.unspentNotes.some(
(note2) => JSON.stringify(note2[0]) === JSON.stringify(note[0]),
),
);

this.pendingUnspentNotes.set(
txid,
(await this.addTransaction(txhex, true)).map((n) => n[0]),
decryptedNewNotes.map((n) => n[0]),
);
return {
hex: txhex,
Expand Down

0 comments on commit 9c5d78a

Please sign in to comment.