Class: Secp256k1HdWallet
@shareledgerjs/client.Secp256k1HdWallet
A wallet for protobuf based signing using SIGN_MODE_DIRECT
Implements
OfflineDirectSigner
Constructors
constructor
• Protected
new Secp256k1HdWallet(mnemonic
, options
)
Parameters
Name | Type |
---|---|
mnemonic | EnglishMnemonic |
options | Secp256k1HdWalletConstructorOptions |
Properties
accounts
• Private
Readonly
accounts: any
Derivation instructions
getKeyPair
• Private
getKeyPair: any
secret
• Private
Readonly
secret: any
Base secret
seed
• Private
Readonly
seed: any
BIP39 seed
deserializeTypeV1
▪ Static
Private
deserializeTypeV1: any
Accessors
mnemonic
• get
mnemonic(): string
Returns
string
Methods
getAccounts
▸ getAccounts(): Promise
<readonly AccountData
[]>
Returns
Promise
<readonly AccountData
[]>
Implementation of
OfflineDirectSigner.getAccounts
getAccountsWithPrivkeys
▸ getAccountsWithPrivkeys(): Promise
<readonly AccountDataWithPrivkey
[]>
Returns
Promise
<readonly AccountDataWithPrivkey
[]>
serialize
▸ serialize(password
): Promise
<string
>
Generates an encrypted serialization of this wallet.
Parameters
Name | Type | Description |
---|---|---|
password | string | The user provided password used to generate an encryption key via a KDF. This is not normalized internally (see "Unicode normalization" to learn more). |
Returns
Promise
<string
>
serializeWithEncryptionKey
▸ serializeWithEncryptionKey(encryptionKey
, kdfConfiguration
): Promise
<string
>
Generates an encrypted serialization of this wallet.
This is an advanced alternative to calling serialize(password)
directly, which allows you to
offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
The caller is responsible for ensuring the key was derived with the given KDF options. If this is not the case, the wallet cannot be restored with the original password.
Parameters
Name | Type |
---|---|
encryptionKey | Uint8Array |
kdfConfiguration | KdfConfiguration |
Returns
Promise
<string
>
signDirect
▸ signDirect(signerAddress
, signDoc
): Promise
<DirectSignResponse
>
Parameters
Name | Type |
---|---|
signerAddress | string |
signDoc | SignDoc |
Returns
Promise
<DirectSignResponse
>
Implementation of
OfflineDirectSigner.signDirect
deserialize
▸ Static
deserialize(serialization
, password
): Promise
<Secp256k1HdWallet
>
Restores a wallet from an encrypted serialization.
Parameters
Name | Type | Description |
---|---|---|
serialization | string | - |
password | string | The user provided password used to generate an encryption key via a KDF. This is not normalized internally (see "Unicode normalization" to learn more). |
Returns
Promise
<Secp256k1HdWallet
>
deserializeWithEncryptionKey
▸ Static
deserializeWithEncryptionKey(serialization
, encryptionKey
): Promise
<Secp256k1HdWallet
>
Restores a wallet from an encrypted serialization.
This is an advanced alternative to calling deserialize(serialization, password)
directly, which allows
you to offload the KDF execution to a non-UI thread (e.g. in a WebWorker).
The caller is responsible for ensuring the key was derived with the given KDF configuration. This can be
done using extractKdfConfiguration(serialization)
and executeKdf(password, kdfConfiguration)
from this package.
Parameters
Name | Type |
---|---|
serialization | string |
encryptionKey | Uint8Array |
Returns
Promise
<Secp256k1HdWallet
>
fromMnemonic
▸ Static
fromMnemonic(mnemonic
, options?
): Promise
<Secp256k1HdWallet
>
Restores a wallet from the given BIP39 mnemonic.
Parameters
Name | Type | Description |
---|---|---|
mnemonic | string | Any valid English mnemonic. |
options? | Partial <Secp256k1HdWalletOptions > | An optional Secp256k1HdWalletOptions object optionally containing a bip39Password, hdPaths, and prefix. |
Returns
Promise
<Secp256k1HdWallet
>
generate
▸ Static
generate(length?
, options?
): Promise
<Secp256k1HdWallet
>
Generates a new wallet with a BIP39 mnemonic of the given length.
Parameters
Name | Type | Description |
---|---|---|
length? | 18 | 24 | 12 | 15 | 21 | The number of words in the mnemonic (12, 15, 18, 21 or 24). |
options? | Partial <Secp256k1HdWalletOptions > | An optional Secp256k1HdWalletOptions object optionally containing a bip39Password, hdPaths, and prefix. |
Returns
Promise
<Secp256k1HdWallet
>
validateMnemonic
▸ Static
validateMnemonic(mnemonic
): boolean
Validates whether the input mnemonic is valid.
Parameters
Name | Type | Description |
---|---|---|
mnemonic | string | Any valid English mnemonic. |
Returns
boolean
true if the input mnemonic is valid, otherwise false.