Skip to content

Commit ea812a3

Browse files
committed
Improve hdkey a bit
1 parent 142cd6b commit ea812a3

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/hdkey.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export interface Versions {
4040
const hash160 = (data: Uint8Array) => ripemd160(sha256(data));
4141
const fromU32 = (data: Uint8Array) => createView(data).getUint32(0, false);
4242
const toU32 = (n: number) => {
43-
if (!Number.isSafeInteger(n) || n < 0 || n >= 2 ** 32) {
44-
throw new Error(`Invalid number=${n}. Should be [0, 2**32)`);
43+
if (!Number.isSafeInteger(n) || n < 0 || n > 2 ** 32 - 1) {
44+
throw new Error(`Invalid number=${n}. Should be from 1 to 2 ** 32 - 1`);
4545
}
4646
const buf = new Uint8Array(4);
4747
createView(buf).setUint32(0, n, false);
@@ -219,11 +219,6 @@ export class HDKey {
219219
}
220220

221221
public deriveChild(index: number): HDKey {
222-
if (!Number.isSafeInteger(index) || index < 0 || index >= 2 ** 32) {
223-
throw new Error(
224-
`Child index should be positive 32-bit integer, not ${index}`
225-
);
226-
}
227222
if (!this.pubKey || !this.chainCode) {
228223
throw new Error("No publicKey or chainCode set");
229224
}

0 commit comments

Comments
 (0)