Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electrum-mnemonic

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrum-mnemonic - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

src/encoding.d.ts

42

package.json
{
"name": "electrum-mnemonic",
"version": "0.0.1",
"version": "1.0.0",
"description": "Electrum Mnemonics (electrum v2 and greater)",
"main": "index.js",
"main": "src/index.js",
"types": "src/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "npm run clean && tsc -p tsconfig.json",
"clean": "rm -rf src",
"coverage": "npm run unit -- --coverage",
"format": "npm run prettier -- --write",
"format:ci": "npm run prettier -- --check",
"gitdiff": "git diff --exit-code",
"gitdiff:ci": "npm run build && npm run gitdiff",
"lint": "tslint -p tsconfig.json -c tslint.json",
"prepublishOnly": "npm run test && npm run gitdiff",
"prettier": "prettier 'ts_src/**/*.ts' --ignore-path ./.prettierignore",
"test": "npm run build && npm run format:ci && npm run lint && npm run unit",
"unit": "jest --config=jest.json --runInBand"
},

@@ -21,6 +33,28 @@ "repository": {

"license": "MIT",
"files": [
"src"
],
"bugs": {
"url": "https://github.com/bitcoinjs/electrum-mnemonic/issues"
},
"homepage": "https://github.com/bitcoinjs/electrum-mnemonic#readme"
"homepage": "https://github.com/bitcoinjs/electrum-mnemonic#readme",
"devDependencies": {
"@types/create-hash": "^1.2.2",
"@types/create-hmac": "^1.1.0",
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"@types/pbkdf2": "^3.0.0",
"@types/randombytes": "^2.0.0",
"jest": "^25.3.0",
"prettier": "^2.0.4",
"ts-jest": "^25.3.1",
"tslint": "^6.1.1",
"typescript": "^3.8.3"
},
"dependencies": {
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"pbkdf2": "^3.0.17",
"randombytes": "^2.1.0"
}
}
# Electrum Mnemonics (electrum v2 and greater)
WIP
[![Build Status](https://travis-ci.org/bitcoinjs/electrum-mnemonic.png?branch=master)](https://travis-ci.org/bitcoinjs/electrum-mnemonic)
[![NPM](https://img.shields.io/npm/v/electrum-mnemonic.svg)](https://www.npmjs.org/package/electrum-mnemonic)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
## Install
```bash
npm install electrum-mnemonic
```
## Usage
* Generate a mnemonic (English only for now)
```js
const mn = require('electrum-mnemonic')
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)
```
* Convert mnemonic into 64 byte seed (for bip32)
```js
const mn = require('electrum-mnemonic')
const phrase = mn.generateMnemonic()
const seed = mn.mnemonicToSeedSync(phrase, { passphrase: 'extrapassword' })
console.log(seed)
// async
;(async () => {
const seed2 = await mn.mnemonicToSeed(phrase)
// no extra password so seed and seed2 should be different
console.log(seed2)
})()
```
* Skip valid version prefix check
```js
const mn = require('electrum-mnemonic')
const seed = mn.mnemonicToSeedSync('abc', { skipCheck: true })
console.log(seed)
```
* Custom prefixes for checking
```js
const mn = require('electrum-mnemonic')
const phrase = mn.generateMnemonic('fed')
const seed = mn.mnemonicToSeedSync(phrase, { validPrefixes: mn.PREFIXES.concat(['fed']) })
console.log(seed)
```
index.js
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc