Class: Wallet
The Wallet class.
Table of contents
Constructors
Methods
- backup
- changeStrongholdPassword
- clearStrongholdPassword
- createAccount
- destroy
- emitTestEvent
- getAccount
- getAccountIndexes
- getAccounts
- getClient
- getChrysalisData
- getSecretManager
- generateEd25519Address
- getLedgerNanoStatus
- isStrongholdPasswordAvailable
- listen
- clearListeners
- recoverAccounts
- removeLatestAccount
- restoreBackup
- setClientOptions
- setStrongholdPassword
- setStrongholdPasswordClearInterval
- startBackgroundSync
- stopBackgroundSync
- storeMnemonic
- updateNodeAuth
Constructors
constructor
• new Wallet(options
)
Parameters
Name | Type | Description |
---|---|---|
options | WalletOptions | Wallet options. |
Methods
backup
▸ backup(destination
, password
): Promise
<void
>
Backup the data to a Stronghold snapshot.
Parameters
Name | Type |
---|---|
destination | string |
password | string |
Returns
Promise
<void
>
changeStrongholdPassword
▸ changeStrongholdPassword(currentPassword
, newPassword
): Promise
<void
>
Change the Stronghold password.
Parameters
Name | Type |
---|---|
currentPassword | string |
newPassword | string |
Returns
Promise
<void
>
clearStrongholdPassword
▸ clearStrongholdPassword(): Promise
<void
>
Clear the Stronghold password from memory.
Returns
Promise
<void
>
createAccount
▸ createAccount(data
): Promise
<Account
>
Create a new account.
Parameters
Name | Type |
---|---|
data | CreateAccountPayload |
Returns
Promise
<Account
>
destroy
▸ destroy(): Promise
<void
>
Destroy the Wallet and drop its database connection.
Returns
Promise
<void
>
emitTestEvent
▸ emitTestEvent(event
): Promise
<void
>
Emit a provided event for testing of the event system.
Parameters
Name | Type |
---|---|
event | WalletEvent |
Returns
Promise
<void
>
getAccount
▸ getAccount(accountId
): Promise
<Account
>
Get an account by its alias or index.
Parameters
Name | Type |
---|---|
accountId | AccountId |
Returns
Promise
<Account
>
getAccountIndexes
▸ getAccountIndexes(): Promise
<number
[]>
Get all account indexes.
Returns
Promise
<number
[]>
getAccounts
▸ getAccounts(): Promise
<Account
[]>
Get all accounts.
Returns
Promise
<Account
[]>
getClient
▸ getClient(): Promise
<Client
>
Get client.
Returns
Promise
<Client
>
getChrysalisData
▸ getChrysalisData(): Promise
<Record
<string
, string
>>
Get chrysalis data.
Returns
Promise
<Record
<string
, string
>>
getSecretManager
▸ getSecretManager(): Promise
<SecretManager
>
Get secret manager.
Returns
Promise
<SecretManager
>
generateEd25519Address
▸ generateEd25519Address(accountIndex
, addressIndex
, options?
, bech32Hrp?
): Promise
<string
>
Generate an address without storing it.
Parameters
Name | Type |
---|---|
accountIndex | number |
addressIndex | number |
options? | GenerateAddressOptions |
bech32Hrp? | string |
Returns
Promise
<string
>
getLedgerNanoStatus
▸ getLedgerNanoStatus(): Promise
<LedgerNanoStatus
>
Get the status for a Ledger Nano.
Returns
Promise
<LedgerNanoStatus
>
isStrongholdPasswordAvailable
▸ isStrongholdPasswordAvailable(): Promise
<boolean
>
Check if the Stronghold password has been set.
Returns
Promise
<boolean
>
listen
▸ listen(eventTypes
, callback
): Promise
<void
>
Listen to wallet events with a callback. An empty array will listen to all possible events.
Parameters
Name | Type |
---|---|
eventTypes | WalletEventType [] |
callback | (error : Error , event : Event ) => void |
Returns
Promise
<void
>
clearListeners
▸ clearListeners(eventTypes
): Promise
<void
>
Clear the callbacks for provided events. An empty array will clear all listeners.
Parameters
Name | Type |
---|---|
eventTypes | WalletEventType [] |
Returns
Promise
<void
>
recoverAccounts
▸ recoverAccounts(accountStartIndex
, accountGapLimit
, addressGapLimit
, syncOptions
): Promise
<Account
[]>
Find accounts with unspent outputs.
Parameters
Name | Type |
---|---|
accountStartIndex | number |
accountGapLimit | number |
addressGapLimit | number |
syncOptions | SyncOptions |
Returns
Promise
<Account
[]>
removeLatestAccount
▸ removeLatestAccount(): Promise
<void
>
Delete the latest account.
Returns
Promise
<void
>
restoreBackup
▸ restoreBackup(source
, password
, ignoreIfCoinTypeMismatch?
, ignoreIfBech32Mismatch?
): Promise
<void
>
Restore a backup from a Stronghold file Replaces client_options, coin_type, secret_manager and accounts. Returns an error if accounts were already created If Stronghold is used as secret_manager, the existing Stronghold file will be overwritten. If a mnemonic was stored, it will be gone. if ignore_if_coin_type_mismatch is provided client options will not be restored if ignore_if_coin_type_mismatch == true, client options coin type and accounts will not be restored if the cointype doesn't match if ignore_if_bech32_hrp_mismatch == Some("rms"), but addresses have something different like "smr", no accounts will be restored.
Parameters
Name | Type |
---|---|
source | string |
password | string |
ignoreIfCoinTypeMismatch? | boolean |
ignoreIfBech32Mismatch? | string |
Returns
Promise
<void
>
setClientOptions
▸ setClientOptions(clientOptions
): Promise
<void
>
Set ClientOptions.
Parameters
Name | Type |
---|---|
clientOptions | IClientOptions |
Returns
Promise
<void
>
setStrongholdPassword
▸ setStrongholdPassword(password
): Promise
<void
>
Set the Stronghold password.
Parameters
Name | Type |
---|---|
password | string |
Returns
Promise
<void
>
setStrongholdPasswordClearInterval
▸ setStrongholdPasswordClearInterval(intervalInMilliseconds?
): Promise
<void
>
Set the interval after which the Stronghold password gets cleared from memory.
Parameters
Name | Type |
---|---|
intervalInMilliseconds? | number |
Returns
Promise
<void
>
startBackgroundSync
▸ startBackgroundSync(options?
, intervalInMilliseconds?
): Promise
<void
>
Start the background syncing process for all accounts.
Parameters
Name | Type |
---|---|
options? | SyncOptions |
intervalInMilliseconds? | number |
Returns
Promise
<void
>
stopBackgroundSync
▸ stopBackgroundSync(): Promise
<void
>
Stop the background syncing process for all accounts.
Returns
Promise
<void
>
storeMnemonic
▸ storeMnemonic(mnemonic
): Promise
<void
>
Store a mnemonic in the Stronghold snapshot.
Parameters
Name | Type |
---|---|
mnemonic | string |
Returns
Promise
<void
>
updateNodeAuth
▸ updateNodeAuth(url
, auth?
): Promise
<void
>
Update the authentication for the provided node.
Parameters
Name | Type |
---|---|
url | string |
auth? | IAuth |
Returns
Promise
<void
>