electrum-mnemonic
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "electrum-mnemonic", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Electrum Mnemonics (electrum v2 and greater)", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -21,6 +21,6 @@ # Electrum Mnemonics (electrum v2 and greater) | ||
console.log(mn.generateMnemonic()) // default segwit bech32 wallet | ||
console.log(mn.generateMnemonic(mn.PREFIXES.segwit)) // explicit segwit bech32 wallet | ||
console.log(mn.generateMnemonic(mn.PREFIXES.standard)) // legacy p2pkh wallet (base58 address starting with 1) | ||
console.log(mn.generateMnemonic(mn.PREFIXES['2fa'])) // 2fa legacy | ||
console.log(mn.generateMnemonic(mn.PREFIXES['2fa-segwit'])) // legacy p2pkh wallet (base58 address starting with 1) | ||
console.log(mn.generateMnemonic({ prefix: mn.PREFIXES.segwit })) // explicit segwit bech32 wallet | ||
console.log(mn.generateMnemonic({ prefix: mn.PREFIXES.standard })) // legacy p2pkh wallet (base58 address starting with 1) | ||
console.log(mn.generateMnemonic({ prefix: mn.PREFIXES['2fa'] })) // 2fa legacy | ||
console.log(mn.generateMnemonic({ prefix: mn.PREFIXES['2fa-segwit'] })) // legacy p2pkh wallet (base58 address starting with 1) | ||
``` | ||
@@ -56,5 +56,5 @@ | ||
const mn = require('electrum-mnemonic') | ||
const phrase = mn.generateMnemonic('fed') | ||
const phrase = mn.generateMnemonic({ prefix: 'fed' }) | ||
const seed = mn.mnemonicToSeedSync(phrase, { validPrefixes: mn.PREFIXES.concat(['fed']) }) | ||
console.log(seed) | ||
``` |
@@ -8,5 +8,10 @@ /// <reference types="node" /> | ||
}; | ||
export declare function generateMnemonic(prefix?: string, strength?: number, // 12 words x 2048 wordlist === 132 bits | ||
rng?: (size: number) => Buffer, wordlist?: string[]): string; | ||
interface Opts { | ||
interface GenerateOpts { | ||
prefix?: string; | ||
strength?: number; | ||
rng?: (size: number) => Buffer; | ||
wordlist?: string[]; | ||
} | ||
export declare function generateMnemonic(opts?: GenerateOpts): string; | ||
interface SeedOpts { | ||
passphrase?: string; | ||
@@ -16,4 +21,4 @@ validPrefixes?: string[]; | ||
} | ||
export declare function mnemonicToSeedSync(mnemonic: string, opts?: Opts): Buffer; | ||
export declare function mnemonicToSeed(mnemonic: string, opts?: Opts): Promise<Buffer>; | ||
export declare function mnemonicToSeedSync(mnemonic: string, opts?: SeedOpts): Buffer; | ||
export declare function mnemonicToSeed(mnemonic: string, opts?: SeedOpts): Promise<Buffer>; | ||
export {}; |
@@ -14,4 +14,10 @@ "use strict"; | ||
}; | ||
function generateMnemonic(prefix = exports.PREFIXES.segwit, strength = 132, // 12 words x 2048 wordlist === 132 bits | ||
rng = randombytes, wordlist = ENGLISH) { | ||
const DEFAULTGENOPTS = { | ||
prefix: exports.PREFIXES.segwit, | ||
strength: 132, | ||
rng: randombytes, | ||
wordlist: ENGLISH, | ||
}; | ||
function generateMnemonic(opts) { | ||
const { prefix, strength, rng, wordlist } = Object.assign({}, DEFAULTGENOPTS, opts); | ||
const wordBitLen = encoding_1.bitlen(wordlist.length); | ||
@@ -18,0 +24,0 @@ const wordCount = Math.ceil(strength / wordBitLen); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45019
2333