Skip to main content

Class: AccountManager

The AccountManager class.

Table of contents

Methods

Methods

backup

backup(destination, password): Promise<void>

Backup the data to a Stronghold snapshot.

Parameters

NameType
destinationstring
passwordstring

Returns

Promise<void>


bech32ToHex

bech32ToHex(bech32Address): Promise<string>

Transform a bech32 encoded address to a hex encoded address

Parameters

NameType
bech32Addressstring

Returns

Promise<string>


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(payload): Promise<Account>

Create a new account.

Parameters

NameType
payloadCreateAccountPayload

Returns

Promise<Account>


destroy

destroy(): Promise<void>

Destroy the AccountManager 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>


generateMnemonic

generateMnemonic(): Promise<string>

Generate a random BIP39 mnemonic.

Returns

Promise<string>


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


generateAddress

generateAddress(accountIndex, internal, addressIndex, options?, bech32Hrp?): Promise<string>

Generate an address without storing it.

Parameters

NameType
accountIndexnumber
internalboolean
addressIndexnumber
options?GenerateAddressOptions
bech32Hrp?string

Returns

Promise<string>


getNodeInfo

getNodeInfo(url?, auth?): Promise<NodeInfoWrapper>

Get the node info.

Parameters

NameType
url?string
auth?Auth

Returns

Promise<NodeInfoWrapper>


getLedgerNanoStatus

getLedgerNanoStatus(): Promise<LedgerNanoStatus>

Get the status for a Ledger Nano.

Returns

Promise<LedgerNanoStatus>


hexToBech32

hexToBech32(hex, bech32Hrp?): Promise<string>

Transform hex encoded address to bech32 encoded address. If no bech32Hrp is provided, the AccountManager will attempt to retrieve it from the NodeInfo. If this does not succeed, it will default to the Shimmer testnet bech32Hrp.

Parameters

NameType
hexstring
bech32Hrp?string

Returns

Promise<string>


isStrongholdPasswordAvailable

isStrongholdPasswordAvailable(): Promise<boolean>

Check if the Stronghold password has been set.

Returns

Promise<boolean>


listen

listen(eventTypes, callback): void

Listen to wallet events with a callback. An empty array will listen to all possible events.

Parameters

NameType
eventTypesEventType[]
callback(error: Error, result: string) => void

Returns

void


clearListeners

clearListeners(eventTypes): Promise<void>

Clear the callbacks for provided events. An empty array will clear all listeners.

Parameters

NameType
eventTypesEventType[]

Returns

Promise<void>


recoverAccounts

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

Find accounts with unspent outputs.

Parameters

NameType
accountStartIndexnumber
accountGapLimitnumber
addressGapLimitnumber
syncOptionsAccountSyncOptions

Returns

Promise<Account[]>


removeLatestAccount

removeLatestAccount(): Promise<void>

Delete the latest account.

Returns

Promise<void>


restoreBackup

restoreBackup(source, password): 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.

Parameters

NameType
sourcestring
passwordstring

Returns

Promise<void>


setClientOptions

setClientOptions(clientOptions): Promise<void>

Set ClientOptions.

Parameters

NameType
clientOptionsClientOptions

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?AccountSyncOptions
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>


verifyMnemonic

verifyMnemonic(mnemonic): Promise<void>

Verify if a mnemonic is a valid BIP39 mnemonic.

Parameters

NameType
mnemonicstring

Returns

Promise<void>


updateNodeAuth

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

Update the authentication for the provided node.

Parameters

NameType
urlstring
auth?Auth

Returns

Promise<void>