Variables
Const CIPHER
CIPHER: "aes-128-ctr" = "aes-128-ctr"
Const CKB_CLI_ORIGIN
CKB_CLI_ORIGIN: "ckb-cli" = "ckb-cli"
Const EMPTY_BUFFER
EMPTY_BUFFER: Buffer = Buffer.from("")
Const ENTROPY_NOT_DIVISIBLE
ENTROPY_NOT_DIVISIBLE: "Entropy should be divisable by 4" = `Entropy should be divisable by 4`
Const ENTROPY_TOO_LONG
ENTROPY_TOO_LONG: string = `Entropy should be shorter than ${MAX_ENTROPY_SIZE + 1}`
Const ENTROPY_TOO_SHORT
ENTROPY_TOO_SHORT: string = `Entropy should be longer than ${MIN_ENTROPY_SIZE - 1}`
Const INVALID_CHECKSUM
INVALID_CHECKSUM: "Invalid checksum" = `Invalid checksum`
Const INVALID_MNEMONIC
INVALID_MNEMONIC: "Invalid mnemonic" = `Invalid mnemonic`
Const KEY_LEN
KEY_LEN: 64 = 64
Const MAX_ENTROPY_SIZE
MAX_ENTROPY_SIZE: 32 = 32
Const MAX_WORDS_SIZE
MAX_WORDS_SIZE: 24 = 24
Const MIN_ENTROPY_SIZE
MIN_ENTROPY_SIZE: 16 = 16
Const MIN_WORDS_SIZE
MIN_WORDS_SIZE: 12 = 12
Const PBKDF2_ROUNDS
PBKDF2_ROUNDS: 2048 = 2048
Const RADIX
RADIX: 2048 = 2048
Const WORDS_TOO_LONG
WORDS_TOO_LONG: string = `Words should be shorter than ${MAX_WORDS_SIZE + 1}`
Const WORDS_TOO_SHORT
WORDS_TOO_SHORT: string = `Words should be longer than ${MIN_WORDS_SIZE - 1}`
Const _default
Const _default
Const _default
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[]
assertHexString
Const ec
ec: ec = new EC("secp256k1")
Const ec
ec: ec = new EC("secp256k1")
@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")