Skip to content

Commit

Permalink
Handle the case in which loaded data is incompatible with current ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
panleone committed Oct 10, 2024
1 parent 2ac706d commit cfd91e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/pivx_shield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,17 @@ export class PIVXShield {
shieldData.commitmentTree,
);
pivxShield.mapNullifierNote = new Map(
Object.entries(shieldData.mapNullifierNote),
Object.entries(shieldData.mapNullifierNote ?? {}),
);
pivxShield.diversifierIndex = shieldData.diversifierIndex;
pivxShield.unspentNotes = shieldData.unspentNotes;
return pivxShield;

// Shield activity update: mapNullifierNote must be present in the shieldData
let success = true;
if (!shieldData.mapNullifierNote) {
success = false;
}
return { pivxShield, success };
}

/**
Expand Down Expand Up @@ -568,6 +574,7 @@ export class PIVXShield {
this.unspentNotes = [];
this.pendingSpentNotes = new Map();
this.pendingUnspentNotes = new Map();
this.mapNullifierNote = new Map();
}
}

Expand Down

0 comments on commit cfd91e5

Please sign in to comment.