diff --git a/types/bip39/bip39-tests.ts b/types/bip39/bip39-tests.ts new file mode 100644 index 0000000000..1ec9611bb8 --- /dev/null +++ b/types/bip39/bip39-tests.ts @@ -0,0 +1,14 @@ +import * as bip39 from 'bip39'; + +// Test generate a random mnemonic +const mnemonic: string = bip39.generateMnemonic(); + +// Test generate a random mnemonic with strength +bip39.generateMnemonic(64); + +// Test mnemonic to seed +const seedHex: string = bip39.mnemonicToSeedHex('basket actual'); +const seed: Buffer = bip39.mnemonicToSeed('basket actual'); + +// Test validation +bip39.validateMnemonic(mnemonic); diff --git a/types/bip39/index.d.ts b/types/bip39/index.d.ts new file mode 100644 index 0000000000..a5d58cf961 --- /dev/null +++ b/types/bip39/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for bip39 2.4 +// Project: https://github.com/bitcoinjs/bip39 +// Definitions by: Satana Charuwichitratana +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export const wordlists: { + EN: string[]; + JA: string[]; + chinese_simplified: string[]; + chinese_traditional: string[]; + english: string[]; + french: string[]; + italian: string[]; + japanese: string[]; + spanish: string[]; +}; + +export function entropyToMnemonic(entropyHex: string, wordlist?: string[]): string; + +export function generateMnemonic(strength?: number, rng?: (size: number) => Buffer, wordlist?: string[]): string; + +export function mnemonicToEntropy(mnemonic: string, wordlist?: string[]): string; + +export function mnemonicToSeed(mnemonic: string, password?: string): Buffer; + +export function mnemonicToSeedHex(mnemonic: string, password?: string): string; + +export function validateMnemonic(mnemonic: string, wordlist?: string[]): boolean; diff --git a/types/bip39/tsconfig.json b/types/bip39/tsconfig.json new file mode 100644 index 0000000000..d44c1197ad --- /dev/null +++ b/types/bip39/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bip39-tests.ts" + ] +} diff --git a/types/bip39/tslint.json b/types/bip39/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/bip39/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}