diff --git a/scripts/network.js b/scripts/network.js index a9163c288..aef555e94 100644 --- a/scripts/network.js +++ b/scripts/network.js @@ -169,7 +169,6 @@ export class ExplorerNetwork extends Network { this.blocks ); this.blocks = backend.blocks; - console.log('sync:', this.lastBlockSynced, this.fullSynced); if (this.fullSynced) { await this.getLatestTxs(this.lastBlockSynced); this.lastBlockSynced = this.blocks; @@ -206,6 +205,7 @@ export class ExplorerNetwork extends Network { this.lastWallet ) : this.lastWallet; + await this.wallet.loadAddresses(); for (const tx of iPage.transactions.reverse()) { await mempool.updateMempool(mempool.parseTransaction(tx)); } @@ -216,6 +216,7 @@ export class ExplorerNetwork extends Network { this.lastWallet ) : this.lastWallet; + await this.wallet.loadAddresses(); if (firstPage.transactions) { for (const tx of firstPage.transactions.reverse()) { await mempool.updateMempool(mempool.parseTransaction(tx)); @@ -233,8 +234,8 @@ export class ExplorerNetwork extends Network { this.lastBlockSynced = nBlockHeights.length == 0 ? 0 : nBlockHeights.sort().at(-1); this.fullSynced = true; - activityDashboard.update(10); - stakingDashboard.update(10); + await activityDashboard.update(50); + await stakingDashboard.update(50); } /** diff --git a/scripts/wallet.js b/scripts/wallet.js index e2adaeb86..f41fe75ef 100644 --- a/scripts/wallet.js +++ b/scripts/wallet.js @@ -246,33 +246,27 @@ export class Wallet { return this.#masterKey?.isHardwareWallet === true; } - /** - * @param {string} address - address to check - * @return {string?} BIP32 path or null if it's not your address - */ - isOwnAddress(address) { - if (this.#ownAddresses.has(address)) { - return this.#ownAddresses.get(address); - } + async loadAddresses() { const last = getNetwork().lastWallet; this.#addressIndex = this.#addressIndex > last ? this.#addressIndex : last; if (this.isHD()) { for (let i = 0; i <= this.#addressIndex + MAX_ACCOUNT_GAP; i++) { const path = this.getDerivationPath(0, i); - const testAddress = this.#masterKey.getAddress(path); - if (address === testAddress) { - this.#ownAddresses.set(address, path); - return path; - } + const address = await this.#masterKey.getAddress(path); + this.#ownAddresses.set(address, path); } } else { - const value = address === this.getKeyToExport() ? ':)' : null; - this.#ownAddresses.set(address, value); - return value; + this.#ownAddresses.set(await this.getKeyToExport(), ':)'); } - this.#ownAddresses.set(address, null); - return null; + } + + /** + * @param {string} address - address to check + * @return {Promise} BIP32 path or null if it's not your address + */ + async isOwnAddress(address) { + return this.#ownAddresses.get(address) ?? null; } /**