Variables
Const CIPHER
CIPHER: "aes-128-ctr" = "aes-128-ctr"
Defined in packages/hd/src/keystore.ts:28
Const CKB_CLI_ORIGIN
CKB_CLI_ORIGIN: "ckb-cli" = "ckb-cli"
Defined in packages/hd/src/keystore.ts:29
Const EMPTY_BUFFER
EMPTY_BUFFER: Buffer = Buffer.from("")
Defined in packages/hd/src/keychain.ts:8
Const ENTROPY_NOT_DIVISIBLE
ENTROPY_NOT_DIVISIBLE: "Entropy should be divisable by 4" = `Entropy should be divisable by 4`
Defined in packages/hd/src/mnemonic/index.ts:15
Const ENTROPY_TOO_LONG
ENTROPY_TOO_LONG: string = `Entropy should be shorter than ${MAX_ENTROPY_SIZE + 1}`
Defined in packages/hd/src/mnemonic/index.ts:16
Const ENTROPY_TOO_SHORT
ENTROPY_TOO_SHORT: string = `Entropy should be longer than ${MIN_ENTROPY_SIZE - 1}`
Defined in packages/hd/src/mnemonic/index.ts:19
Const INVALID_CHECKSUM
INVALID_CHECKSUM: "Invalid checksum" = `Invalid checksum`
Defined in packages/hd/src/mnemonic/index.ts:14
Const INVALID_MNEMONIC
INVALID_MNEMONIC: "Invalid mnemonic" = `Invalid mnemonic`
Defined in packages/hd/src/mnemonic/index.ts:13
Const KEY_LEN
KEY_LEN: 64 = 64
Defined in packages/hd/src/mnemonic/index.ts:7
Const MAX_ENTROPY_SIZE
MAX_ENTROPY_SIZE: 32 = 32
Defined in packages/hd/src/mnemonic/index.ts:9
Const MAX_WORDS_SIZE
MAX_WORDS_SIZE: 24 = 24
Defined in packages/hd/src/mnemonic/index.ts:11
Const MIN_ENTROPY_SIZE
MIN_ENTROPY_SIZE: 16 = 16
Defined in packages/hd/src/mnemonic/index.ts:8
Const MIN_WORDS_SIZE
MIN_WORDS_SIZE: 12 = 12
Defined in packages/hd/src/mnemonic/index.ts:10
Const PBKDF2_ROUNDS
PBKDF2_ROUNDS: 2048 = 2048
Defined in packages/hd/src/mnemonic/index.ts:6
Const RADIX
RADIX: 2048 = 2048
Defined in packages/hd/src/mnemonic/index.ts:5
Const WORDS_TOO_LONG
WORDS_TOO_LONG: string = `Words should be shorter than ${MAX_WORDS_SIZE + 1}`
Defined in packages/hd/src/mnemonic/index.ts:22
Const WORDS_TOO_SHORT
WORDS_TOO_SHORT: string = `Words should be longer than ${MIN_WORDS_SIZE - 1}`
Defined in packages/hd/src/mnemonic/index.ts:23
Const _default
Defined in packages/hd/lib/mnemonic/index.d.ts:9
Const _default
Defined in packages/hd/lib/key.d.ts:9
Const _default
Defined in packages/hd/lib/index.d.ts:8
Type declaration
AccountExtendedPublicKey: typeof AccountExtendedPublicKey
AddressType: typeof AddressType
ExtendedPrivateKey: typeof ExtendedPrivateKey
ExtendedPublicKey: typeof ExtendedPublicKey
IncorrectPassword: typeof IncorrectPassword
InvalidKeystore: typeof InvalidKeystore
Keychain: typeof Keychain
Keystore: typeof Keystore
UnsupportedCipher: typeof UnsupportedCipher
XPubStore: typeof XPubStore
Const _default
_default: string []
Defined in packages/hd/lib/mnemonic/word_list.d.ts:1
assertHexString
Defined in packages/hd/src/helper.ts:2
Const ec
ec: ec = new EC("secp256k1")
Defined in packages/hd/src/key.ts:5
Const ec
ec: ec = new EC("secp256k1")
Defined in packages/hd/src/keychain.ts:6
@ckb-lumos/hd
HD & Mnemonic implementation for lumos.
Usage
Create a new HD wallet.
const { mnemonic, ExtendedPrivateKey, Keystore } = require("@ckb-lumos/hd") const m = mnemonic.generateMnemonic() const seed = mnemonic.mnemonicToSeedSync(m) const extendedPrivateKey = ExtendedPrivateKey.fromSeed(seed) const keystore = Keystore.create(extendedPrivateKey, "Your password") // save keystore file keystore.save("you path, only dir") // load keystore file const keystore = Keystore.load("you file path, with file name")
XPub support.
const { XPubStore } = require("@ckb-lumos/hd") // load from xpub file. const xpub = XPubStore.load("you path") // to AccountExtendedPublicKey const accountExtendedPublicKey = xpub.toAccountExtendedPublicKey() // save xpub file. xpub.save("your path")
Browsers
This package enforces key management by importing
buffer
,stream
,crypto
,fs
andpath
packages, which are not available in browser environment. If you want to use '@lumos/hd' in your front-end project, please include polyfill to your project module bundle. Here is a webpack example:resolve: { ... fallback: { fs: false, buffer: require.resolve('buffer/'), stream: require.resolve('stream-browserify'), path: require.resolve('path-browserify'), crypto: require.resolve('crypto-browserify'), }, plugins: [ new webpack.ProvidePlugin({ process: 'process/browser', Buffer: ['buffer', 'Buffer'], }), ], }
You'll need to install
buffer
,stream-browserify
,path-browserify
andcrypto-browserify
also.