@tevm/voltaire / HDWallet
HDWallet
HD Wallet (BIP-32) - Hierarchical Deterministic Key DerivationType Aliases
HDWallet
HDWallet =Defined in: src/crypto/HDWallet/ExtendedKeyType.ts:10HDKey&object
Type Declaration
[brand]
readonly[brand]:"ExtendedKey"
calculateCreate2Address()
calculateCreate2Address(salt,initCode):Uint8Array
Parameters
salt
Uint8Array
initCode
Uint8Array
Returns
Uint8Array
calculateCreateAddress()
calculateCreateAddress(nonce):Uint8Array
Parameters
nonce
bigint
Returns
Uint8Array
canDeriveHardened()
canDeriveHardened(this):boolean
Parameters
this
HDWallet
Returns
boolean
deriveChild()
deriveChild(this,index):HDWallet
Parameters
this
HDWallet
index
number
Returns
HDWallet
derivePath()
derivePath(this,path):HDWallet
Parameters
this
HDWallet
path
string
Returns
HDWallet
getChainCode()
getChainCode(this):ChainCode
Parameters
this
HDWallet
Returns
ChainCode
getPrivateKey()
getPrivateKey(this):PrivateKey
Parameters
this
HDWallet
Returns
PrivateKey
getPublicKey()
getPublicKey(this):PublicKey
Parameters
this
HDWallet
Returns
PublicKey
toExtendedPrivateKey()
toExtendedPrivateKey(this):string
Parameters
this
HDWallet
Returns
string
toExtendedPublicKey()
toExtendedPublicKey(this):string
Parameters
this
HDWallet
Returns
string
toPublic()
toPublic(this):HDWallet
Parameters
this
HDWallet
Returns
HDWallet
Variables
HDWallet
Defined in: src/crypto/HDWallet/HDWallet.js:91 HDWallet namespace - collection of HD wallet operationsconstHDWallet:object
Type Declaration
BIP44_PATH
BIP44_PATH:Standard BIP-44 path template functions. Format: m / purpose’ / coin_type’ / account’ / change / address_indexReadonly<{BTC: (account?,index?) =>string;ETH: (account?,index?) =>string; }>
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
canDeriveHardened()
canDeriveHardened: (Check if extended key can derive hardened children. Only keys with private key material can derive hardened paths.key) =>boolean
Parameters
key
HDWallet
Extended key to check
Returns
boolean
True if key has private key and can derive hardened children, false if public-only
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
CoinType
CoinType:Standard BIP-44 coin type constants.Readonly<{BTC:0;BTC_TESTNET:1;ETC:61;ETH:60; }>
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
deriveBitcoin()
deriveBitcoin: (Derive Bitcoin address key using BIP-44 standard path. Path format: m/44’/0’/account’/0/indexkey,account?,index?) =>HDWallet
Parameters
key
HDWallet
Root HD key with private key
account?
number = 0
BIP-44 account index (default: 0)
index?
number = 0
Address index (default: 0)
Returns
HDWallet
Derived extended key for Bitcoin address
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If derivation path is invalid or derivation failsExample
deriveChild()
deriveChild: (Derive child key by index using BIP-32. Supports both normal and hardened derivation.key,index) =>HDWallet
Parameters
key
HDWallet
Parent extended key
index
number
Child index (add HARDENED_OFFSET for hardened derivation)
Returns
HDWallet
Derived child extended key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If derivation fails or index is invalidExample
deriveEthereum()
deriveEthereum: (Derive Ethereum address key using BIP-44 standard path. Path format: m/44’/60’/account’/0/indexkey,account?,index?) =>HDWallet
Parameters
key
HDWallet
Root HD key with private key
account?
number = 0
BIP-44 account index (default: 0)
index?
number = 0
Address index (default: 0)
Returns
HDWallet
Derived extended key for Ethereum address
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If derivation path is invalid or derivation failsExample
derivePath()
derivePath: (Derive child key using BIP-32 derivation path. Supports hierarchical paths with hardened (’) and normal derivation.key,path) =>HDWallet
Parameters
key
HDWallet
Parent extended key
path
string
BIP-32 derivation path (e.g., “m/44’/60’/0’/0/0”)
Returns
HDWallet
Derived child extended key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If path format is invalid or derivation failsExample
fromExtendedKey()
fromExtendedKey: (Create HD key from extended private key string. Deserializes base58-encoded xprv key.xprv) =>HDWallet
Parameters
xprv
string
Base58-encoded extended private key (xprv…)
Returns
HDWallet
Extended key with private key material
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If extended key format is invalid or decoding failsExample
fromPublicExtendedKey()
fromPublicExtendedKey: (Create HD key from extended public key string. Cannot derive hardened children from public-only keys.xpub) =>HDWallet
Parameters
xpub
string
Base58-encoded extended public key (xpub…)
Returns
HDWallet
Extended key with public key only (no private key)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If extended public key format is invalid or decoding failsExample
fromSeed()
fromSeed: (Create root HD key from BIP-39 seed. Master key for hierarchical deterministic wallet.seed) =>HDWallet
Parameters
seed
Uint8Array<ArrayBufferLike>
BIP-39 seed bytes (typically 64 bytes from mnemonic, must be 16-64 bytes)
Returns
HDWallet
Root extended key for BIP-32 derivation
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If seed length is not between 16 and 64 bytesThrows
If master key derivation failsExample
generateMnemonic()
generateMnemonic: (Generate BIP-39 mnemonic from entropystrength?) =>Promise<string[]>
Parameters
strength?
Entropy strength in bits128 | 256
Returns
Promise<string[]>
Mnemonic words
Throws
If strength is invalid or generation failsgetChainCode()
getChainCode: (Get chain code from extended key. Chain code is used in BIP-32 child key derivation.key) =>Uint8Array<ArrayBufferLike> |null
Parameters
key
HDWallet
Extended key
Returns
Uint8Array<ArrayBufferLike> | null
32-byte chain code or null if not available
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
getPrivateKey()
getPrivateKey: (Get private key bytes from extended key. Returns null for public-only keys.key) =>Uint8Array<ArrayBufferLike> |null
Parameters
key
HDWallet
Extended key
Returns
Uint8Array<ArrayBufferLike> | null
32-byte secp256k1 private key or null if public-only key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
getPublicKey()
getPublicKey: (Get public key bytes from extended key. Returns compressed secp256k1 public key.key) =>Uint8Array<ArrayBufferLike> |null
Parameters
key
HDWallet
Extended key
Returns
Uint8Array<ArrayBufferLike> | null
33-byte compressed secp256k1 public key or null
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
HARDENED_OFFSET
HARDENED_OFFSET: number
First hardened child index offset for BIP-32 derivation.
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
isHardenedPath()
isHardenedPath: (Check if BIP-32 path contains hardened derivation. Hardened paths use ’ or h suffix (e.g., 44’ or 44h).path) =>boolean
Parameters
path
string
BIP-32 derivation path
Returns
boolean
True if path contains hardened derivation indicator (’ or h), false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
isValidPath()
isValidPath: (Validate BIP-32 derivation path format. Checks syntax but not semantic validity.path) =>boolean
Parameters
path
string
Derivation path to validate
Returns
boolean
True if path matches BIP-32 format (m/number’/number/…), false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
mnemonicToSeed()
mnemonicToSeed: (Convert BIP-39 mnemonic to seedmnemonic,password?) =>Promise<Uint8Array<ArrayBufferLike>>
Parameters
mnemonic
Mnemonic words (array or space-separated string)string | string[]
password?
string
Optional passphrase
Returns
Promise<Uint8Array<ArrayBufferLike>>
512-bit seed
Throws
If mnemonic conversion failsparseIndex()
parseIndex: (Parse BIP-32 index string with hardened notation. Converts “0’” or “0h” to hardened index (adds HARDENED_OFFSET).indexStr) =>number
Parameters
indexStr
string
Index string (e.g., “0”, “0’”, “0h”)
Returns
number
Numeric index (hardened indices have HARDENED_OFFSET added)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If index format is invalid or not a non-negative integerExample
toExtendedPrivateKey()
toExtendedPrivateKey: (Serialize extended key to base58-encoded xprv string. Requires key with private key material.key) =>string
Parameters
key
HDWallet
Extended key with private key
Returns
string
Base58-encoded extended private key (xprv…)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key does not have private key materialExample
toExtendedPublicKey()
toExtendedPublicKey: (Serialize extended key to base58-encoded xpub string. Produces public-only key that cannot derive hardened children.key) =>string
Parameters
key
HDWallet
Extended key
Returns
string
Base58-encoded extended public key (xpub…)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key does not have public keyExample
toPublic()
toPublic: (Create public-only version of extended key (neutered key). Removes private key material, keeping only public key and chain code.key) =>HDWallet
Parameters
key
HDWallet
Extended key with or without private key
Returns
HDWallet
Public-only extended key (cannot derive hardened children)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key does not have public keyExample
validateMnemonic()
validateMnemonic: (Validate BIP-39 mnemonic checksummnemonic) =>Promise<boolean>
Parameters
mnemonic
Mnemonic words (array or space-separated string)string | string[]
Returns
Promise<boolean>
True if valid
