136 lines
4.9 KiB
Plaintext
136 lines
4.9 KiB
Plaintext
_section: HD Wallet @<hdnodes>
|
|
|
|
The Hierarchal Desterministic (HD) Wallet was a standard
|
|
created for Bitcoin, but lends itself well to a wide variety of
|
|
Blockchains which rely on secp256k1 private keys.
|
|
|
|
For a more detailed technical understanding:
|
|
|
|
- [BIP-32](link-bip-32) - the hierarchal deterministic description
|
|
- [BIP-39](link-bip-39) - the method used to derive the BIP-32 seed
|
|
from human-readable sequences of words (i.e. a mnemonic)
|
|
- [BIP-44](link-bip-44) - a standard defined to make BIP-32 easy
|
|
to adapt to any future compatible blockchain
|
|
|
|
_subsection: Types
|
|
|
|
_heading: Constants @<hdnodes--defaultpath> @SRC<hdnode:defaultPath>
|
|
|
|
_property: ethers.utils.defaultPath => "m/44'/60'/0'/0/0"
|
|
The default path for Ethereum in an HD Wallet
|
|
|
|
|
|
_heading: Mnemonic @<Mnemonic>
|
|
|
|
_property: mnemonic.phrase => string
|
|
The mnemonic phrase for this mnemonic. It is 12, 15, 18, 21 or 24 words long
|
|
and separated by the whitespace specified by the ``locale``.
|
|
|
|
_property: mnemonic.path => string
|
|
The HD path for this mnemonic.
|
|
|
|
_property: mnemonic.locale => string
|
|
The language of the wordlist this mnemonic is using.
|
|
|
|
|
|
_subsection: HDNode @<HDNode> @SRC<hdnode:class.HDNode>
|
|
|
|
_heading: Creating Instances @<HDNode--creating>
|
|
|
|
_property: ethers.HDNode.fromMnemonic(phrase [, password [, wordlist ] ]) => [[HDNode]] @<HDNode-fromMnemonic> @SRC<hdnode>
|
|
Return the [[HDNode]] for //phrase// with the optional //password//
|
|
and //wordlist//.
|
|
|
|
_property: ethers.HDNode.fromSeed(aBytesLike) => [[HDNode]] @<HDNode-fromSeed> @SRC<hdnode>
|
|
Return the [[HDNode]] for the seed //aBytesLike//.
|
|
|
|
_property: ethers.HDNode.fromExtendedKey(extendedKey) => [[HDNode]] @<HDNode-fromExtendedKey> @SRC<hdnode>
|
|
Return the [[HDNode]] for the //extendedKey//. If //extendedKey// was
|
|
neutered, the **HDNode** will only be able to compute addresses and not
|
|
private keys.
|
|
|
|
|
|
_heading: Properties @<HDNode--properties>
|
|
|
|
_property: hdNode.privateKey => string<[[DataHexString]]<32>>
|
|
The private key for this HDNode.
|
|
|
|
_property: hdNode.publicKey => string<[[DataHexString]]<33>>
|
|
The (compresses) public key for this HDNode.
|
|
|
|
_property: hdNode.fingerprint => string<[[DataHexString]]<4>>
|
|
The fingerprint is meant as an index to quickly match parent and
|
|
children nodes together, however collisions may occur and software
|
|
should verify matching nodes.
|
|
|
|
Most developers will not need to use this.
|
|
|
|
_property: hdNode.parentFingerprint => string<[[DataHexString]]<4>>
|
|
The fingerprint of the parent node. See //fingerprint// for more
|
|
details.
|
|
|
|
Most developers will not need to use this.
|
|
|
|
_property: hdNode.address => string<[[address]]>
|
|
The address of this HDNode.
|
|
|
|
_property: hdNode.mnemonic => [[Mnemonic]]
|
|
The mnemonic of this HDNode, if known.
|
|
|
|
_property: hdNode.path => string
|
|
The path of this HDNode, if known. If the //mnemonic// is also known,
|
|
this will match ``mnemonic.path``.
|
|
|
|
_property: hdNode.chainCode => string<[[DataHexString]]<32>>
|
|
The chain code is used as a non-secret private key which is then used
|
|
with EC-multiply to provide the ability to derive addresses without
|
|
the private key of child non-hardened nodes.
|
|
|
|
Most developers will not need to use this.
|
|
|
|
_property: hdNode.index => number
|
|
The index of this HDNode. This will match the last component of
|
|
the //path//.
|
|
|
|
Most developers will not need to use this.
|
|
|
|
_property: hdNode.depth => number
|
|
The depth of this HDNode. This will match the number of components
|
|
(less one, the ``m/``) of the //path//.
|
|
|
|
Most developers will not need to use this.
|
|
|
|
_property: hdNode.extendedKey => string
|
|
A serialized string representation of this HDNode. Not all properties
|
|
are included in the serialization, such as the mnemonic and path, so
|
|
serializing and deserializing (using the ``fromExtendedKey`` class
|
|
method) will result in reduced information.
|
|
|
|
|
|
_heading: Methods @<HDNode--methods>
|
|
|
|
_property: hdNode.neuter() => [[HDNode]] @<HDNode-neuter> @SRC<hdnode>
|
|
Return a new instance of //hdNode// with its private key removed
|
|
but all other properties preserved. This ensures that the key
|
|
can not leak the private key of itself or any derived children,
|
|
but may still be used to compute the addresses of itself and
|
|
any non-hardened children.
|
|
|
|
_property: hdNode.derivePath(path) => [[HDNode]] @<HDNode-derivePath> @SRC<hdnode>
|
|
Return a new [[HDNode]] which is the child of //hdNode// found
|
|
by deriving //path//.
|
|
|
|
|
|
|
|
_subsection: Other Functions @<HDNode--utilities>
|
|
|
|
_property: ethers.utils.mnemonicToSeed(phrase [ , password]) => string<[[DataHexString]]<64>> @<utils-mnemonicToSeed> @SRC<hdnode>
|
|
Convert a mnemonic phrase to a seed, according to [BIP-39](link-bip-39).
|
|
|
|
_property: ethers.utils.mnemonicToEntropy(phrase [ , wordlist ]) => string<[[DataHexString]]> @<utils-mnemonicToEntropy> @SRC<hdnode>
|
|
Convert a mnemonic phrase to its entropy, according to [BIP-39](link-bip-39).
|
|
|
|
_property: ethers.utils.isValidMnemonic(phrase [ , wordlist ]) => boolean @<utils-isValidMnemonic> @SRC<hdnode>
|
|
Returns true if //phrase// is a valid mnemonic phrase, by
|
|
testing the checksum.
|