electrum-mnemonic
Advanced tools
Comparing version 0.0.1 to 1.0.0
{ | ||
"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) | ||
``` |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
37782
10
2194
0
59
4
11
+ Addedcreate-hash@^1.2.0
+ Addedcreate-hmac@^1.1.7
+ Addedpbkdf2@^3.0.17
+ Addedrandombytes@^2.1.0
+ Addedcipher-base@1.0.6(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)