export const DIFFICULTY_SEND = 0xfffffff800000000n
export const HARDENED_OFFSET = 0x80000000
export const HEXCHAR = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] as const
+export const MAX_DERIVATIONS = 1_000
export const MAX_RAW = 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFFn
export const MAX_SUPPLY = 133_248_297_920_938_463_463_374_607_431_768_211_455n
export const NONCE_LENGTH = 24
import { UUID } from 'node:crypto'
import { parentPort, threadId } from 'node:worker_threads'
import { TaskData } from '.'
-import { BIP44_COIN_NANO } from '../constants'
+import { BIP44_COIN_NANO, MAX_DERIVATIONS } from '../constants'
import { dec, utf8 } from '../convert'
import { Bip39, Bip44, Blake2b, WalletAesGcm } from '../crypto'
import { VaultError } from '../errors'
* wallet seed at a specified index and then returns the public key. The wallet
* must be unlocked prior to derivation.
*/
-function derive (index?: number | Uint32Array): Promise<Record<string, number | ArrayBuffer>> {
+function derive (index?: Uint32Array): Promise<Record<string, number | ArrayBuffer>> {
try {
_timer.pause()
if (_locked) {
if (index == null) {
throw new VaultError('Invalid wallet account index(es)')
}
+ if (index.length > MAX_DERIVATIONS) {
+ throw new VaultError('Maximum 1000 accounts per call')
+ }
const promises = []
const values = typeof index === 'number' ? [index] : index.values()
for (const i of values) {
import { WalletType } from '.'
import { Account } from '../account'
+import { MAX_DERIVATIONS } from '../constants'
import { Ledger } from '../ledger'
import { Vault } from '../vault'
if (to - from > 100) {
console.warn('libnemo performance may degrade when deriving many accounts at once')
}
- if (to - from > 1_000) {
+ if (to - from > MAX_DERIVATIONS) {
throw new RangeError('Maximum 1000 accounts per call')
}
const output = new Map<number, Account>()