Skip to content

Commit

Permalink
Merge pull request #582 from keerifox/handle-frontier-errors
Browse files Browse the repository at this point in the history
Fix 20 unused accounts being added on wallet import, and malformed lightweight proof of work requests for unused accounts
  • Loading branch information
Joohansson authored Jun 1, 2023
2 parents cd6d388 + 6bed180 commit a04d7b5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/app/services/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,12 @@ export class WalletService {
for (const accountID in batchResponse.frontiers) {
if (batchResponse.frontiers.hasOwnProperty(accountID)) {
const frontier = batchResponse.frontiers[accountID];
if (frontier !== batchAccounts[accountID].publicKey) {
usedIndices.push(batchAccounts[accountID].index);
const frontierIsValidHash = this.util.nano.isValidHash(frontier);

if (frontierIsValidHash === true) {
if (frontier !== batchAccounts[accountID].publicKey) {
usedIndices.push(batchAccounts[accountID].index);
}
}
}
}
Expand Down Expand Up @@ -754,7 +758,14 @@ export class WalletService {

walletAccount.balanceFiat = this.util.nano.rawToMnano(walletAccount.balance).times(fiatPrice).toNumber();

walletAccount.frontier = frontiers.frontiers[accountID] || null;
const walletAccountFrontier = frontiers.frontiers[accountID];
const walletAccountFrontierIsValidHash = this.util.nano.isValidHash(walletAccountFrontier);

walletAccount.frontier = (
(walletAccountFrontierIsValidHash === true)
? walletAccountFrontier
: null
);

walletBalance = walletBalance.plus(walletAccount.balance);
walletPendingInclUnconfirmed = walletPendingInclUnconfirmed.plus(accountBalancePendingInclUnconfirmed);
Expand Down

0 comments on commit a04d7b5

Please sign in to comment.