Skip to main content

Class: Wallet

The Wallet class.

Table of contents

Constructors

Methods

Constructors

constructor

new Wallet(options)

Parameters

NameTypeDescription
optionsWalletOptionsWallet options.

Methods

backup

backup(destination, password): Promise<void>

Backup the data to a Stronghold snapshot.

Parameters

NameType
destinationstring
passwordstring

Returns

Promise<void>


changeStrongholdPassword

changeStrongholdPassword(currentPassword, newPassword): Promise<void>

Change the Stronghold password.

Parameters

NameType
currentPasswordstring
newPasswordstring

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

NameType
dataCreateAccountPayload

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

NameType
eventWalletEvent

Returns

Promise<void>


getAccount

getAccount(accountId): Promise<Account>

Get an account by its alias or index.

Parameters

NameType
accountIdAccountId

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

NameType
accountIndexnumber
addressIndexnumber
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

NameType
eventTypesWalletEventType[]
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

NameType
eventTypesWalletEventType[]

Returns

Promise<void>


recoverAccounts

recoverAccounts(accountStartIndex, accountGapLimit, addressGapLimit, syncOptions): Promise<Account[]>

Find accounts with unspent outputs.

Parameters

NameType
accountStartIndexnumber
accountGapLimitnumber
addressGapLimitnumber
syncOptionsSyncOptions

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

NameType
sourcestring
passwordstring
ignoreIfCoinTypeMismatch?boolean
ignoreIfBech32Mismatch?string

Returns

Promise<void>


setClientOptions

setClientOptions(clientOptions): Promise<void>

Set ClientOptions.

Parameters

NameType
clientOptionsIClientOptions

Returns

Promise<void>


setStrongholdPassword

setStrongholdPassword(password): Promise<void>

Set the Stronghold password.

Parameters

NameType
passwordstring

Returns

Promise<void>


setStrongholdPasswordClearInterval

setStrongholdPasswordClearInterval(intervalInMilliseconds?): Promise<void>

Set the interval after which the Stronghold password gets cleared from memory.

Parameters

NameType
intervalInMilliseconds?number

Returns

Promise<void>


startBackgroundSync

startBackgroundSync(options?, intervalInMilliseconds?): Promise<void>

Start the background syncing process for all accounts.

Parameters

NameType
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

NameType
mnemonicstring

Returns

Promise<void>


updateNodeAuth

updateNodeAuth(url, auth?): Promise<void>

Update the authentication for the provided node.

Parameters

NameType
urlstring
auth?IAuth

Returns

Promise<void>