From 0214269f709e2c1828695a6fee06bb7eb1e566d6 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 3 Aug 2026 13:05:01 -0700 Subject: [PATCH] Fix range of unopened account search and cap batch at 100. --- src/lib/wallet/unopened.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/wallet/unopened.ts b/src/lib/wallet/unopened.ts index fc5ef37..ebdc59a 100644 --- a/src/lib/wallet/unopened.ts +++ b/src/lib/wallet/unopened.ts @@ -10,14 +10,14 @@ export async function _unopened (wallet: Wallet, rpc: unknown, batchSize: unknow if (!(rpc instanceof Rpc)) { throw new TypeError('Invalid RPC endpoint', { cause: rpc }) } - if (typeof batchSize !== 'number' || !Number.isSafeInteger(batchSize) || batchSize < 1) { - throw new TypeError('Invalid batch size', { cause: batchSize }) + if (typeof batchSize !== 'number' || batchSize < 1 || 100 < batchSize) { + throw new TypeError('Batch size must be 1-100', { cause: batchSize }) } - if (typeof from !== 'number' || !Number.isSafeInteger(batchSize) || batchSize < 0) { + if (typeof from !== 'number' || from < 0 || 0xffffffff < from) { throw new TypeError('Invalid starting account index', { cause: from }) } - const to = from + batchSize - const accounts = await wallet.accounts(from, to - 1) + const to = (from + batchSize > 0xffffffff) ? 0xffffffff : from + batchSize + const accounts = await wallet.accounts(from, to) const addresses = [] for (const account of accounts.values()) { addresses.push(account.address) @@ -39,5 +39,5 @@ export async function _unopened (wallet: Wallet, rpc: unknown, batchSize: unknow } } } - return await _unopened(wallet, rpc, batchSize, from + batchSize) + return await _unopened(wallet, rpc, batchSize, to) } -- 2.52.0