]> git.codecow.com Git - libnemo.git/commitdiff
Increase visible account derivation limit now that batches are possible.
authorChris Duncan <chris@codecow.com>
Sat, 8 Aug 2026 06:42:26 +0000 (23:42 -0700)
committerChris Duncan <chris@codecow.com>
Sat, 8 Aug 2026 06:42:26 +0000 (23:42 -0700)
src/lib/wallet/accounts.ts
test/test.derive-accounts.mjs

index ed5fc1651930140158216bb5eac8302732b1f9bb..bc8710424d853a3b19c8aea844cc3ac7de78edac 100644 (file)
@@ -21,7 +21,7 @@ export async function _accounts (type: WalletType, accounts: Map<number, Account
        if (from < 0 || 0xffffffff < from || to < 0 || 0xffffffff < to) {
                throw new TypeError('Invalid account range', { cause: `${from}-${to}` })
        }
-       if (to - from > 100) {
+       if (to - from > 10_000) {
                console.warn('libnemo performance may degrade when deriving many accounts at once')
        }
        const output = new Map<number, Account>()
index d3e7cd6570db3f0efc07977c9572002053721265..be80fa5a4d8731d119fa5aae477620a26c7ff6ef 100644 (file)
@@ -10,13 +10,13 @@ import { CUSTOM_TEST_VECTORS, NANO_TEST_VECTORS, TEST_PASSWORD } from './VECTORS
 await Promise.all([\r
        suite('Derive accounts from BIP-44 wallet', async () => {\r
 \r
-               await test('derive the first 10000 accounts from the given BIP-44 seed', async () => {\r
+               await test('derive the first 10,000 accounts from the given BIP-44 seed', async () => {\r
                        const wallet = await Wallet.load('BIP-44', TEST_PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
 \r
                        let start, end\r
                        start = performance.now()\r
-                       await wallet.accounts(0, 10000)\r
+                       await wallet.accounts(0, 10_000)\r
                        end = performance.now()\r
                        console.log('duration', end - start)\r
 \r
@@ -94,6 +94,19 @@ await Promise.all([
 \r
        suite('Derive accounts from BLAKE2b wallet', async () => {\r
 \r
+               await test('derive the first 10,000 accounts from the given BLAKE2b seed', async () => {\r
+                       const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
+                       await wallet.unlock(TEST_PASSWORD)\r
+\r
+                       let start, end\r
+                       start = performance.now()\r
+                       await wallet.accounts(0, 10_000)\r
+                       end = performance.now()\r
+                       console.log('duration', end - start)\r
+\r
+                       await assert.resolves(wallet.destroy())\r
+               })\r
+\r
                await test('derive the second account from the given BLAKE2b seed', async () => {\r
                        const wallet = await Wallet.load('BLAKE2b', TEST_PASSWORD, NANO_TEST_VECTORS.BLAKE2B_SEED)\r
                        await wallet.unlock(TEST_PASSWORD)\r
@@ -169,6 +182,19 @@ await Promise.all([
        suite('Derive accounts from Exodus wallet', async () => {\r
                const { ADDRESS_0, ADDRESS_1, BIP39_SEED_0, BIP39_SEED_1, PUBLIC_0, PUBLIC_1 } = CUSTOM_TEST_VECTORS.EXODUS\r
 \r
+               await test('derive the first 10,000 accounts from the given Exodus seed', async () => {\r
+                       const wallet = await Wallet.load('Exodus', TEST_PASSWORD, BIP39_SEED_0)\r
+                       await wallet.unlock(TEST_PASSWORD)\r
+\r
+                       let start, end\r
+                       start = performance.now()\r
+                       await wallet.accounts(0, 10_000)\r
+                       end = performance.now()\r
+                       console.log('duration', end - start)\r
+\r
+                       await assert.resolves(wallet.destroy())\r
+               })\r
+\r
                await test('derive the first account from the given Exodus seed', async () => {\r
                        const wallet = await Wallet.load('Exodus', TEST_PASSWORD, BIP39_SEED_0)\r
                        await wallet.unlock(TEST_PASSWORD)\r