Constructor
new PrivateKey(optionsopt)
Create an hd private key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
HDPrivateKeyOptions |
<optional> |
Properties:
Name | Type | Description |
---|---|---|
depth |
Number | |
parentFingerPrint |
Number | |
childIndex |
Number | |
chainCode |
Buffer | |
privateKey |
Buffer |
- Source:
Methods
(static) fromBase58(xkey, networkopt, nullable) → {HDPrivateKey}
Instantiate an HD private key from a base58 string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
xkey |
Base58String | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- HDPrivateKey
(static) fromKey(key, entropy) → {HDPrivateKey}
Create an hd private key from a key and entropy bytes.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer | |
entropy |
Buffer |
- Source:
Returns:
- Type
- HDPrivateKey
(static) fromMnemonic(mnemonic, passphraseopt, nullable) → {HDPrivateKey}
Instantiate an hd private key from a mnemonic.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
mnemonic |
Mnemonic | ||
passphrase |
String |
<optional> <nullable> |
- Source:
Returns:
- Type
- HDPrivateKey
(static) fromPhrase(phrase) → {HDPrivateKey}
Instantiate an hd private key from a phrase.
Parameters:
Name | Type | Description |
---|---|---|
phrase |
String |
- Source:
Returns:
- Type
- HDPrivateKey
(static) fromSeed(seed) → {HDPrivateKey}
Instantiate an hd private key from a 512 bit seed.
Parameters:
Name | Type | Description |
---|---|---|
seed |
Buffer |
- Source:
Returns:
- Type
- HDPrivateKey
(static) generate() → {HDPrivateKey}
Generate an hd private key.
- Source:
Returns:
- Type
- HDPrivateKey
(static) isBase58(data, networkopt, nullable) → {Boolean}
Test whether an object is in the form of a base58 xprivkey.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
String | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- Boolean
(static) isHDPrivateKey(obj) → {Boolean}
Test whether an object is an HDPrivateKey.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
- Source:
Returns:
- Type
- Boolean
(static) isRaw(data, networkopt, nullable) → {Boolean}
Test whether a buffer has a valid network prefix.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Buffer | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- Boolean
(static) isValidPath(path) → {Boolean}
Test whether a string is a valid path.
Parameters:
Name | Type | Description |
---|---|---|
path |
String |
- Source:
Returns:
- Type
- Boolean
compare(key) → {Number}
Compare a key against an object.
Parameters:
Name | Type | Description |
---|---|---|
key |
HDPrivateKey |
- Source:
Returns:
- Type
- Number
derive(index, hardenedopt, nullable) → {HDPrivateKey}
Derive a child key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
index |
Number | Derivation index. |
|
hardened |
Boolean |
<optional> <nullable> |
Whether the derivation should be hardened. |
- Source:
Returns:
- Type
- HDPrivateKey
deriveAccount(purpose, type, account) → {HDPrivateKey}
Derive a BIP44 account key.
Parameters:
Name | Type | Description |
---|---|---|
purpose |
Number | |
type |
Number | |
account |
Number |
- Source:
Throws:
Error if key is not a master key.
Returns:
- Type
- HDPrivateKey
derivePath(path) → {HDPrivateKey}
Derive a key from a derivation path.
Parameters:
Name | Type | Description |
---|---|---|
path |
String |
- Source:
Throws:
Error if path
is not a valid path.
Returns:
- Type
- HDPrivateKey
destroy(pub)
Destroy the key (zeroes chain code, privkey, and pubkey).
Parameters:
Name | Type | Description |
---|---|---|
pub |
Boolean | Destroy hd public key as well. |
- Source:
equals(obj) → {Boolean}
Compare a key against an object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
HDPrivateKey |
- Source:
Returns:
- Type
- Boolean
(private) fromBase58(xkey, networkopt, nullable)
Inject properties from base58 key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
xkey |
Base58String | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
fromJSON(json, networkopt, nullable)
Inject properties from json object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
json |
Object | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
(private) fromKey(key, entropy)
Inject properties from privateKey and entropy.
Parameters:
Name | Type | Description |
---|---|---|
key |
Buffer | |
entropy |
Buffer |
- Source:
fromMnemonic(mnemonic, passphraseopt, nullable)
Inject properties from a mnemonic.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
mnemonic |
Mnemonic | ||
passphrase |
String |
<optional> <nullable> |
- Source:
fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
HDPrivateKeyOptions |
- Source:
fromPhrase(phrase)
Inject properties from a mnemonic.
Parameters:
Name | Type | Description |
---|---|---|
phrase |
String |
- Source:
(private) fromSeed(seed)
Inject properties from seed.
Parameters:
Name | Type | Description |
---|---|---|
seed |
Buffer |
- Source:
(private) getID(index) → {String}
Unique HD key ID.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number |
- Source:
Returns:
- Type
- String
getJSON(networkopt, nullable) → {Object}
Convert key to a more json-friendly object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- Object
getSize() → {Number}
Calculate serialization size.
- Source:
Returns:
- Type
- Number
isAccount(accountnullable) → {Boolean}
Test whether the key is (most likely) a BIP44 account key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
account |
Number |
<nullable> |
- Source:
Returns:
- Type
- Boolean
isMaster() → {Boolean}
Test whether the key is a master key.
- Source:
Returns:
- Type
- Boolean
read(br, networkopt, nullable)
Inject properties from serialized data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
br |
bio.BufferReader | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
toBase58(networknullable) → {Base58String}
Serialize key to a base58 string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
Network | NetworkType |
<nullable> |
- Source:
Returns:
- Type
- Base58String
toPublic() → {HDPublicKey}
Get HD public key.
- Source:
Returns:
- Type
- HDPublicKey
write(bw, networkopt, nullable) → {BufioWriter}
Write the key to a buffer writer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
bw |
BufioWriter | ||
network |
Network | NetworkType |
<optional> <nullable> |
- Source:
Returns:
- Type
- BufioWriter
xprivkey(networkopt, nullable) → {Base58String}
Get cached base58 xprivkey.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
NetworkType | Network |
<optional> <nullable> |
- Source:
Returns:
- Type
- Base58String
xpubkey(networkopt, nullable) → {Base58String}
Get cached base58 xpubkey.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
network |
NetworkType | Network |
<optional> <nullable> |
- Source:
Returns:
- Type
- Base58String