Class: Mnemonic

hd.Mnemonic(options)

HD Mnemonic

Constructor

new Mnemonic(options)

Create a mnemonic.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
bit Number <nullable>

Bits of entropy (Must be a multiple of 8) (default=256).

entropy Buffer <nullable>

Entropy bytes. Will be generated with options.bits bits of entropy if not present.

phrase String <nullable>

Mnemonic phrase (will be generated if not present).

language String <nullable>

Language.

Source:

Members

(static, constant) languages :Array.<String>

List of languages.

Type:
  • Array.<String>
Default Value:
  • ["simplified chinese","traditional chinese","english","french","italian","japanese","portuguese","spanish"]
Source:

Methods

(static) fromEntropy(entropy, langnullable) → {Mnemonic}

Instantiate mnemonic from entropy.

Parameters:
Name Type Attributes Description
entropy Buffer
lang String <nullable>
Source:
Returns:
Type
Mnemonic

(static) fromPhrase(phrase) → {Mnemonic}

Instantiate mnemonic from a phrase (validates checksum).

Parameters:
Name Type Description
phrase String
Source:
Throws:

on bad checksum

Returns:
Type
Mnemonic

(static) getLanguage(word) → {String}

Determine a single word's language.

Parameters:
Name Type Description
word String
Source:
Throws:

on not found.

Returns:

Language.

Type
String

(static) getWordlist(lang) → {Object}

Retrieve the wordlist for a language.

Parameters:
Name Type Description
lang String
Source:
Returns:
Type
Object

(static) isMnemonic(obj) → {Boolean}

Test whether an object is a Mnemonic.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

destroy()

Destroy the mnemonic (zeroes entropy).

Source:

format() → {String}

Inspect the mnemonic.

Source:
Returns:
Type
String

(private) fromEntropy(entropy, langnullable)

Inject properties from entropy.

Parameters:
Name Type Attributes Description
entropy Buffer
lang String <nullable>
Source:

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromPhrase(phrase)

Inject properties from phrase.

Parameters:
Name Type Description
phrase String
Source:

getEntropy() → {Buffer}

Get or generate entropy.

Source:
Returns:
Type
Buffer

getJSON() → {Object}

Convert mnemonic to a json-friendly object.

Source:
Returns:
Type
Object

getPhrase() → {String}

Generate a mnemonic phrase from chosen language.

Source:
Returns:
Type
String

getSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

(private) read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

toSeed(passphrasenullable) → {Buffer}

Generate the seed.

Parameters:
Name Type Attributes Description
passphrase String <nullable>
Source:
Returns:

pbkdf2 seed.

Type
Buffer

toString() → {String}

Convert the mnemonic to a string.

Source:
Returns:
Type
String

write()

Write the mnemonic to a buffer writer.

Source: