/lib-wallet-seed-bip39-main

Primary LanguageJavaScriptApache License 2.0Apache-2.0

๐ŸŒฑ lib-wallet-seed-bip39

A robust implementation of BIP39 seed generation and management. This is lib is a wrapper around bip32 and bip39

๐Ÿ’ผ Wallet SDK

This library is part of the Wallet SDK.

๐Ÿ”ง Usage

Here's a quick example of how to use Bip39Seed:

const Bip39Seed = require('lib-wallet-seed-bip39');

async function example() {
  // Generate a new seed with a random mnemonic
  const newSeed = await Bip39Seed.generate();
  console.log(newSeed);

  // Generate a seed with a specific mnemonic
  const mnemonic = 'your twelve word mnemonic phrase goes here';
  const specificSeed = await Bip39Seed.generate(mnemonic);
  console.log(specificSeed);

  // Export the seed
  const exportedSeed = specificSeed.exportSeed();
  console.log(exportedSeed);
}

example();

๐Ÿ“˜ API

Bip39Seed

Constructor

  • new Bip39Seed(config)
    • config.seed: (optional) The seed buffer
    • config.mnemonic: (required) The mnemonic phrase

Static Methods

  • Bip39Seed.generate(mnemonic)
    • Generates a new Bip39Seed instance
    • mnemonic: (optional) A specific mnemonic phrase to use

Instance Methods

  • exportSeed(opts)
    • Exports the seed and mnemonic
    • opts.string: (optional) If false, returns an object instead of a JSON string

๐Ÿงช Testing

We use the Brittle testing framework for our unit tests. To run the tests for this package, use the following command:

npm run test