Merge pull request #582 from keerifox/handle-frontier-errors

Fix 20 unused accounts being added on wallet import, and malformed lightweight proof of work requests for unused accounts
This commit is contained in:
Joohansson (Json) 2023-06-01 22:30:16 +02:00 committed by GitHub
commit a04d7b54a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -512,6 +512,9 @@ export class WalletService {
for (const accountID in batchResponse.frontiers) {
if (batchResponse.frontiers.hasOwnProperty(accountID)) {
const frontier = batchResponse.frontiers[accountID];
const frontierIsValidHash = this.util.nano.isValidHash(frontier);
if (frontierIsValidHash === true) {
if (frontier !== batchAccounts[accountID].publicKey) {
usedIndices.push(batchAccounts[accountID].index);
}
@ -519,6 +522,7 @@ export class WalletService {
}
}
}
}
// Add accounts
if (usedIndices.length > 0) {
@ -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);