Typescript - Generic HD Wallet, inspired by ethereumjs-wallet with sigutil replacement
import { HDKey, Wallet, ZilliqaUtil } from "generichd-wallet";
Constructors:
fromPrivateKey(input, [type])
- create an instance based on a raw private keyfromExtendedPrivateKey(input, [type])
- create an instance based on a BIP32 extended private key (xprv)fromPublicKey(input, [type])
- create an instance based on a public key (certain methods will not be available)
Note: type
is the coin symbol required to determine which sigutil to load. Supported at the moment ETH / ZIL.
type
Defaults to ETH
Instance methods:
getPrivateKey()
- return the private keygetPublicKey()
- return the public keygetAddress()
- return the address
All of the above instance methods return a Buffer. Use the String
suffixed versions for a string output, such as getPrivateKeyString()
.
To use BIP32 HD wallets, first include the hdkey
submodule:
import { HDKey } from "generichd-wallet";
Constructors:
fromMasterSeed(seed, [type])
- create an instance based on a seedfromExtendedKey(key, [type])
- create an instance based on a BIP32 extended private or public key
Note: type
is the coin symbol required to determine which sigutil to load. Supported at the moment ETH / ZIL.
type
Defaults to ETH
For the seed we suggest to use bip39 to create one from a BIP39 mnemonic.
Instance methods:
privateExtendedKey()
- return a BIP32 extended private key (xprv)publicExtendedKey()
- return a BIP32 extended public key (xpub)derivePath(path)
- derive a node based on a path (e.g. m/44'/0'/0/1)deriveChild(index)
- derive a node based on a child indexgetWallet()
- return aWallet
instance as seen above
MIT License
Inspired by ethereumjs-wallet by Alex Beregszaszi
Copyright (C) 2018: cryptoland.tech
Author: Micky Socaci