if (!/^[0-9A-Fa-f]{64}$/.test(hash ?? '')) {
throw new Error('Invalid hash. Must be a 64-character hex string.')
}
- if (difficulty && !/^[1-9A-Fa-f]{1}[0-9A-Fa-f]{0,15}$/.test(difficulty)) {
+ if (difficulty && !/^[0-9A-Fa-f]{0,16}$/.test(difficulty)) {
throw new Error('Invalid difficulty. Must be a hexadecimal string between 1-FFFFFFFFFFFFFFFF.')
}
if (action === 'work_validate' && !/^[0-9A-Fa-f]{16}$/.test(work ?? '')) {
throw new TypeError(`Invalid difficulty ${options.difficulty}`)
}
}
- const difficulty = (typeof options?.difficulty !== 'bigint' || options.difficulty < 1n || options.difficulty > 0xffffffffffffffffn)
+ const difficulty = (typeof options?.difficulty !== 'bigint' || options.difficulty < 0n || options.difficulty > 0xffffffffffffffffn)
? 0xfffffff800000000n
: options.difficulty
const effort = (typeof options?.effort !== 'number' || options.effort < 0x1 || options.effort > 0x20)
throw new TypeError(`Invalid difficulty ${options.difficulty}`)
}
}
- const difficulty = (typeof options?.difficulty !== 'bigint' || options.difficulty < 1n || options.difficulty > 0xffffffffffffffffn)
+ const difficulty = (typeof options?.difficulty !== 'bigint' || options.difficulty < 0n || options.difficulty > 0xffffffffffffffffn)
? 0xfffffff800000000n
: options.difficulty
this.#debug = !!(options?.debug)