ethers.js/docs.wrm/api/utils/hdnode.wrm

136 lines
4.9 KiB
Plaintext
Raw Permalink Normal View History

2020-05-08 03:24:40 -04:00
_section: HD Wallet @<hdnodes>
2020-02-17 17:56:13 -05:00
2021-02-08 14:52:31 -05:00
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
2020-02-17 17:56:13 -05:00
_subsection: Types
2020-05-08 03:24:40 -04:00
_heading: Constants @<hdnodes--defaultpath> @SRC<hdnode:defaultPath>
2020-02-17 17:56:13 -05:00
_property: ethers.utils.defaultPath => "m/44'/60'/0'/0/0"
The default path for Ethereum in an HD Wallet
2020-05-08 03:24:40 -04:00
_heading: Mnemonic @<Mnemonic>
2020-02-17 17:56:13 -05:00
_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.
2020-05-08 03:24:40 -04:00
_subsection: HDNode @<HDNode> @SRC<hdnode:class.HDNode>
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_heading: Creating Instances @<HDNode--creating>
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_property: ethers.HDNode.fromMnemonic(phrase [, password [, wordlist ] ]) => [[HDNode]] @<HDNode-fromMnemonic> @SRC<hdnode>
Return the [[HDNode]] for //phrase// with the optional //password//
2020-02-17 17:56:13 -05:00
and //wordlist//.
2020-05-08 03:24:40 -04:00
_property: ethers.HDNode.fromSeed(aBytesLike) => [[HDNode]] @<HDNode-fromSeed> @SRC<hdnode>
Return the [[HDNode]] for the seed //aBytesLike//.
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_property: ethers.HDNode.fromExtendedKey(extendedKey) => [[HDNode]] @<HDNode-fromExtendedKey> @SRC<hdnode>
Return the [[HDNode]] for the //extendedKey//. If //extendedKey// was
2020-02-17 17:56:13 -05:00
neutered, the **HDNode** will only be able to compute addresses and not
private keys.
2020-05-08 03:24:40 -04:00
_heading: Properties @<HDNode--properties>
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_property: hdNode.privateKey => string<[[DataHexString]]<32>>
2020-02-17 17:56:13 -05:00
The private key for this HDNode.
2020-05-08 03:24:40 -04:00
_property: hdNode.publicKey => string<[[DataHexString]]<33>>
2020-02-17 17:56:13 -05:00
The (compresses) public key for this HDNode.
2020-05-08 03:24:40 -04:00
_property: hdNode.fingerprint => string<[[DataHexString]]<4>>
2020-02-17 17:56:13 -05:00
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.
2020-05-08 03:24:40 -04:00
_property: hdNode.parentFingerprint => string<[[DataHexString]]<4>>
2020-02-17 17:56:13 -05:00
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.
2020-05-08 03:24:40 -04:00
_property: hdNode.mnemonic => [[Mnemonic]]
2020-02-17 17:56:13 -05:00
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``.
2020-05-08 03:24:40 -04:00
_property: hdNode.chainCode => string<[[DataHexString]]<32>>
2020-02-17 17:56:13 -05:00
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.
2020-05-08 03:24:40 -04:00
_heading: Methods @<HDNode--methods>
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_property: hdNode.neuter() => [[HDNode]] @<HDNode-neuter> @SRC<hdnode>
2020-02-17 17:56:13 -05:00
Return a new instance of //hdNode// with its private key removed
2020-10-03 13:30:15 -03:00
but all other properties preserved. This ensures that the key
2020-02-17 17:56:13 -05:00
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.
2020-05-08 03:24:40 -04:00
_property: hdNode.derivePath(path) => [[HDNode]] @<HDNode-derivePath> @SRC<hdnode>
Return a new [[HDNode]] which is the child of //hdNode// found
2020-02-17 17:56:13 -05:00
by deriving //path//.
2020-05-08 03:24:40 -04:00
_subsection: Other Functions @<HDNode--utilities>
2020-02-17 17:56:13 -05:00
2020-05-08 03:24:40 -04:00
_property: ethers.utils.mnemonicToSeed(phrase [ , password]) => string<[[DataHexString]]<64>> @<utils-mnemonicToSeed> @SRC<hdnode>
2020-02-17 17:56:13 -05:00
Convert a mnemonic phrase to a seed, according to [BIP-39](link-bip-39).
2020-05-08 03:24:40 -04:00
_property: ethers.utils.mnemonicToEntropy(phrase [ , wordlist ]) => string<[[DataHexString]]> @<utils-mnemonicToEntropy> @SRC<hdnode>
2020-02-17 17:56:13 -05:00
Convert a mnemonic phrase to its entropy, according to [BIP-39](link-bip-39).
2020-05-08 03:24:40 -04:00
_property: ethers.utils.isValidMnemonic(phrase [ , wordlist ]) => boolean @<utils-isValidMnemonic> @SRC<hdnode>
2020-02-17 17:56:13 -05:00
Returns true if //phrase// is a valid mnemonic phrase, by
testing the checksum.